Class: ActiveRecord::Validations::CNPJValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/validates_as_cnpj.rb

Constant Summary collapse

@@black_list =
%w(00000000000000 11111111111111 22222222222222 33333333333333 
44444444444444 55555555555555 66666666666666 77777777777777
88888888888888 99999999999999)

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



9
10
11
12
13
14
# File 'lib/validates_as_cnpj.rb', line 9

def validate_each(record, attribute, value)
 return if valid? value
 record.errors.add(attribute, 
                   I18n.translate('activerecord.errors.messages.invalid', :default => 'invalid'), 
                   options.merge(:value => value))
end