Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue validating with spaces and letters #44

Open
emafriedrich opened this issue Jun 22, 2024 · 1 comment
Open

Issue validating with spaces and letters #44

emafriedrich opened this issue Jun 22, 2024 · 1 comment

Comments

@emafriedrich
Copy link

We have a issue regarding validations with strings that has spaces and letters

> const v = require('cpf-cnpj-validator')
> v.cpf.isValid('   16704533672     d ')
true
> v.cpf.isValid('   16704533672     ')
true
> v.cpf.isValid('   16704533672     asdfasdfasdf')
true
> v.cpf.isValid('   16704533672     asdfasdfasdf as34343434')
false
> v.cpf.isValid('   16704533672     asdfasdfasdf as3')
false
> v.cpf.isValid('   16704533672     asdfasdfasdf asasdfasdf asdfasdf asdf asdf asdfasdf')
true
> v.cpf.isValid('asdfasdf16704533672asdfasdf')
true

We consider this as a big issue. You will know if is intended this behavior.

Just to let you know.

Thanks

@patrickJramos
Copy link

isValid only validates the digits in the string by default.

If you need those to fail, you may send a second parameter called strict, for stricter validation. It will return false if there are any non-digit characters, except "." and "-", which are ignored.

example: v.cpf.isValid(value, false).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants