Class: ActiveModel::Validations::CnpjValidator

Inherits:
EachValidator
  • Object
show all
Defined in:
lib/validators/validates_cnpj_format_of.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



4
5
6
7
8
9
# File 'lib/validators/validates_cnpj_format_of.rb', line 4

def validate_each(record, attribute, value)
  record.errors.add(attribute, :invalid_cnpj,
    message: options[:message],
    value: value
  ) unless CNPJ.valid?(value)
end