fnando / cpf_cnpj

🇧🇷 Validate, generate and format CPF/CNPJ numbers. Include command-line tools.
MIT License
239 stars 42 forks source link

is method valid? working? version 0.4.1 #10

Closed rafaelbpa closed 6 years ago

rafaelbpa commented 6 years ago

I'm using version 0.4.1 and method .valid? is always return nil

Rails 3.2.21 and ruby 2.1.5p273

fnando commented 6 years ago

What's the document number you're using?

rafaelbpa commented 6 years ago

I am using CPF.valid?(777), for example. This should return false, am I right? But is returning nil.

fnando commented 6 years ago

This should return false, am I right?

No, you're not. Predicate methods are not required to return booleans. nil is a falsy value, so all you have to do is not checking for data type. If type is important to you, you can coerce it in your code like !!CPF.valid?(777).

rafaelbpa commented 6 years ago

Worked for me. Thank you, Fernando!