Class: BrRailties::CpfValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- BrRailties::CpfValidator
- Defined in:
- app/validators/br_railties/cpf_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'app/validators/br_railties/cpf_validator.rb', line 7 def validate_each(record, attribute, value) cpf = ::CPF.new(value) return if cpf.valid? && value == cpf.stripped record.errors.add( attribute, [:message] || 'CPF inválido (9 caracteres, somente dígitos)' ) end |