Module: ArrayValidator::SubsetValidator
- Defined in:
- lib/array_validator/subset_validator.rb
Class Method Summary collapse
Class Method Details
.call(record, attribute, values, options) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/array_validator/subset_validator.rb', line 3 def self.call(record, attribute, values, ) return if [:subset_of].nil? unlisted_values = values - [:subset_of] return if unlisted_values.empty? = if unlisted_values.size == 1 "#{unlisted_values.first} is not in the list" else "#{unlisted_values.join(', ')} are not in the list" end record.errors[attribute] << end |