Class: Granite::Form::Model::Validations::AssociatedValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- Granite::Form::Model::Validations::AssociatedValidator
- Defined in:
- lib/granite/form/model/validations/associated.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/granite/form/model/validations/associated.rb', line 6 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 |