Module: ActiveModel::Validations::ClassMethods
- Defined in:
- lib/validates_subset.rb
Instance Method Summary collapse
-
#validates_subset(attribute_name, superset, options = {}) ⇒ Object
Validates that an attribute is a subset of an expected set:.
Instance Method Details
#validates_subset(attribute_name, superset, options = {}) ⇒ Object
Validates that an attribute is a subset of an expected set:
class Foo
include ActiveModel::Validations
attr_accessor :thing, :something
validates_subset :thing, ['something', 'another thing', 'a third thing']
validates_subset :something, [:foo, :bar]
end
105 106 107 108 |
# File 'lib/validates_subset.rb', line 105 def validates_subset(attribute_name, superset, = {}) args = ValidatesSubset::Arguments.new(attribute_name, superset, ) validates_with SubsetValidator, _merge_attributes(args.to_validation_attributes) end |