Class: PersonValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- PersonValidator
- Defined in:
- app/validators/person_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
2 3 4 5 6 7 8 |
# File 'app/validators/person_validator.rb', line 2 def validate_each(record, attribute, value) if [:with] == :company && !value.personable.is_a?(Company) record.errors.add(attribute, :company_required) elsif [:with] == :individual && !value.personable.is_a?(Individual) record.errors.add(attribute, :individual_required) end end |