CPF with letters pass validation
Describe the bug I'm not exactly sure if this is expected behaviour or a bug, but if I try to validade a CPF string with letters in it, the validator returns true IF the numbers match a valid CPF.
To Reproduce
// expected return: true
// returns: true
isValidCpf('391.838.380-66')
// expected return: false
// returns: false
isValidCpf('391.838.300-66')
// expected return: false
// returns: false
isValidCpf('391.838.3800-66')
// expected return: false
// returns: true
isValidCpf('foo391.838.380-66')
// expected return: false
// returns: true
isValidCpf('foo391.838.38test0-66')
// expected return: false
// returns: true
isValidCpf('3s9o1.8m3e8.3t8e0s-6t6')
// expected return: false
// returns: false (extra zero at end)
isValidCpf('3s9o1.8m3e8.3t8e0s-6t60')
While it seems nice that isValidCpf() get only the number types, I think this could lead to problems. I don't know, maybe I should use the /helper-only-numbers as well?
Environment:
- OS: macOS Mojave v10.14
- Node: v10.15.0
- @brazilian-utils/validators: v0.1.9
Hello @machado-r, good point... I think that the correct behavior is returning false when you send some letters with the cpf, but internally we remove the letters and work only with numbers, because of that, we return true in your case.
I know that the solution proposed by #42 solve that problem, but with this change, we will change our current behavior and add break changes in that package. @andreoav, @lucassveloso what you think about it?