Class: ArrayValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- ArrayValidator
- Defined in:
- lib/array_validator.rb,
lib/array_validator/subset_validator.rb
Defined Under Namespace
Modules: SubsetValidator
Constant Summary collapse
- I18N_SCOPE =
'activerecord.errors.messages.array'.freeze
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, values) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/array_validator.rb', line 8 def validate_each(record, attribute, values) unless values.is_a? Array record.errors[attribute] << ([:message] || 'is not an array') return end check_subset(record, attribute, values) if [:subset_of].present? check_format(record, attribute, values) if [:format].present? check_duplicates(record, attribute, values) if [:duplicates] == false end |