Class: Muffin::Validation::NestedAttributesValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- Muffin::Validation::NestedAttributesValidator
- Defined in:
- lib/muffin/frostings/validation.rb
Instance Method Summary collapse
Instance Method Details
#validate(entity) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/muffin/frostings/validation.rb', line 6 def validate(entity) entity.attributes.try(:each) do |k, v| Array.wrap(v).each do |e| if e.is_a?(Muffin::NestedAttribute) e.validate entity.errors[k] << :nested_validation_failed if e.errors.present? end end end end |