Class: ActiveModelValidatesIntersectionOf::Validator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- ActiveModelValidatesIntersectionOf::Validator
- Defined in:
- lib/active_model_validates_intersection_of/inclusion_intersection_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/active_model_validates_intersection_of/inclusion_intersection_validator.rb', line 3 def validate_each(record, attribute, value) delimiter = [:in] raise(ArgumentError, "An array must be supplied as the :in option of the configuration hash") unless delimiter.kind_of?(Array) if (value - delimiter).any? record.errors.add(attribute, :inclusion, .except(:in).merge!(value: value)) end end |