leonardocaldas / flutter-cpf-cnpj-validator

A lib to validate CPF and CNPJ numbers.
MIT License
57 stars 17 forks source link

Adds a cpf input format validation #1

Closed lissonpsantos2 closed 5 years ago

lissonpsantos2 commented 5 years ago

I experienced a validation problem when submitting wrong cpfs (like 57abc803.6586-52 and 5780test3658652@mail.com), the plugin returned true. So, I added an extra validation.

Best Regards

leonardocaldas commented 5 years ago

I merged your PR, but then I realized that your scenarios are failing because of the strip that happens just before the validation. So I reverted it and made a new change that you can use for your scenarios.

Because you know you have irregular values to validate, I added a new argument to the is isValid method. Like this:

CPFValidator.isValid("57abc803.6586-52", false) == false

The second argument tells the method not to strip the value before the validation, and for you case it will work.

Anyway, thanks for the PR and feel free to comment or create new pull requests.