Class: Filterameter::Validators::InclusionValidator
- Inherits:
-
ActiveModel::Validations::InclusionValidator
- Object
- ActiveModel::Validations::InclusionValidator
- Filterameter::Validators::InclusionValidator
- Defined in:
- lib/filterameter/validators/inclusion_validator.rb
Overview
# Inclusion Validator
Class InclusionValidator extends ActiveModel::Validations::InclusionValidator to enable validations of multiple values.
## Example
validates: { inclusion: { in: %w[Small Medium Large], allow_multiple_values: true } }
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/filterameter/validators/inclusion_validator.rb', line 15 def validate_each(record, attribute, value) return super unless allow_multiple_values? # any? just provides a mechanism to stop after first error Array.wrap(value).any? { |v| super(record, attribute, v) } end |