Class: StateValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/state_validator.rb,
lib/state_validator/version.rb

Constant Summary collapse

VERSION =
"1.0.1"

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



4
5
6
# File 'lib/state_validator.rb', line 4

def validate_each(record, attribute, value)
  record.errors[attribute] << I18n.t('errors.messages.inclusion') if record.send("#{attribute}_enum".to_sym).include?(value.to_s)
end