Class: Eac::CpfValidator

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

Defined Under Namespace

Classes: Cpf

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



3
4
5
6
7
# File 'lib/eac/cpf_validator.rb', line 3

def validate_each(record, attribute, value)
  return if Cpf.new(value).valid?
  record.errors[attribute] << (options[:message] ||
      'CPF inválido (9 caracteres, somente dígitos)')
end