Class: ActiveModel::Validations::CpfValidator
- Inherits:
-
EachValidator
- Object
- EachValidator
- ActiveModel::Validations::CpfValidator
- Defined in:
- lib/validators/validates_cpf_format_of.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/validators/validates_cpf_format_of.rb', line 4 def validate_each(record, attribute, value) return if value.blank? && [:allow_blank] return if value.nil? && [:allow_nil] record.errors.add(attribute, :invalid_cpf, message: [:message], value: value ) unless CPF.valid?(value) end |