fnando / cpf_cnpj

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

Getting invalid octal digit syntax error for CPF that starts with zero #13

Closed alvarofernandoms closed 5 years ago

alvarofernandoms commented 5 years ago

Example, CPF: 062.446.680-90

Loading development environment (Rails 5.2.1)
2.5.3 :001 > require "cpf_cnpj"
 => false 
2.5.3 :002 > CPF.valid?(06244668090)
Traceback (most recent call last):
SyntaxError ((irb):2: Invalid octal digit)
CPF.valid?(06244668090)
           ^~~~~~~~
alvarofernandoms commented 5 years ago

In these cases, you need just to pass the CPF as a string. My bad! Example:

Loading development environment (Rails 5.2.1)
2.5.3 :001 > require "cpf_cnpj"
 => false 
2.5.3 :002 > CPF.valid?('06244668090')
 => true 
2.5.3 :003 > CPF.valid?('06244668091')
 => false