Skip to content

Commit 7cbd009

Browse files
authored
Fix Verification Digits not being calculated with clean string (#16)
1 parent c0c8958 commit 7cbd009

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/main/kotlin/br/com/colman/simplecpfvalidator/CpfValidator.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import kotlin.math.abs
3939
fun String.isCpf(charactersToIgnore: List<Char> = listOf('.', '-')): Boolean {
4040
val cleanCpf = this.filterNot { it in charactersToIgnore }
4141
if (cleanCpf.containsInvalidCPFChars() || cleanCpf.isInvalidCpfSize() || cleanCpf.isBlacklistedCpf()) return false
42-
return this.hasValidVerificationDigits()
42+
return cleanCpf.hasValidVerificationDigits()
4343
}
4444

4545
/**

src/test/kotlin/br/com/colman/simplecpfvalidator/CpfValidatorTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class CpfValidatorTest : FunSpec({
4343
}
4444

4545
test("Should sanitize the String given replaceable characters and still return true on valid cpfs") {
46-
ValidCpfGenerator.map { "$it..--." }.forAll { cpf -> cpf.isCpf(listOf('.', '-')) }
46+
ValidCpfGenerator.map { "..--.$it..--." }.forAll { cpf -> cpf.isCpf(listOf('.', '-')) }
4747
}
4848

4949
test("Shouldn't sanitize unspecified characters") {

0 commit comments

Comments
 (0)