Class: EacRailsUtils::CpfValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
app/validators/eac_rails_utils/cpf_validator.rb

Defined Under Namespace

Classes: Cpf

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



5
6
7
8
9
10
# File 'app/validators/eac_rails_utils/cpf_validator.rb', line 5

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