Class: ActiveData::Model::Validations::AssociatedValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- ActiveData::Model::Validations::AssociatedValidator
- Defined in:
- lib/active_data/model/validations/associated.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/active_data/model/validations/associated.rb', line 5 def validate_each(record, attribute, value) invalid_records = Array.wrap(value).reject do |r| r.respond_to?(:valid?) && r.valid?(record.validation_context) end record.errors.add(attribute, :invalid, **.merge(value: value)) if invalid_records.present? end |