Class: NestedModelValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- NestedModelValidator
- Defined in:
- lib/sepa_rator/nested_model_validator.rb
Overview
Validates nested ActiveModel objects and propagates their errors. Defined at root level so ActiveModel’s const_get lookup finds it from any namespace. Usage: validates :address, :contact_details, nested_model: true
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/sepa_rator/nested_model_validator.rb', line 7 def validate_each(record, attribute, value) return unless value return if value.valid? value.errors.each { |error| record.errors.add(attribute, error.) } end |