Class: ActiveRecord::Validations::UFBRValidator

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

Constant Summary collapse

@@ufs =
%w(AC AL AM AP BA CE DF ES GO MA MG MS MT PA PB PE PI PR RJ RN RO RR RS SC SE SP TO)

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



8
9
10
11
12
13
# File 'lib/validates_as_uf_br.rb', line 8

def validate_each(record, attribute, value)
  return if valid? value
  record.errors.add(attribute, 
                    I18n.translate('activerecord.errors.messages.invalid', :default => 'invalid'), 
                    options.merge(:value => value))
end