Class: ActiveRecord::Validations::CPFValidator

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

Constant Summary collapse

@@black_list =
%w(12345678909 11111111111 22222222222 33333333333 44444444444
55555555555 66666666666 77777777777 88888888888 99999999999
00000000000)

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



9
10
11
12
13
14
# File 'lib/validates_as_cpf.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