Class: CnpjValidator

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

Overview

Synapses Group

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



5
6
7
8
# File 'lib/cpf_cnpj/cnpj_validator.rb', line 5

def validate_each(record, attribute, value)
  return if value.nil?
  record.errors.add attribute, :invalid unless Cnpj.new(value).valid?
end