Class: ActiveModel::Validations::CnpjValidator
- Inherits:
-
EachValidator
- Object
- EachValidator
- ActiveModel::Validations::CnpjValidator
- Defined in:
- lib/active_model/validations/cnpj_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attr_name, value) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/active_model/validations/cnpj_validator.rb', line 4 def validate_each(record, attr_name, value) return if [:allow_nil] && value.nil? unless(CNPJ.new(value).valid?() rescue false) record.errors.add(attr_name, ([:message] || :cnpj_not_valid)) end end |