Class: AWS::Record::ExclusionValidator
Constant Summary
collapse
- ACCEPTED_OPTIONS =
[:in, :message, :allow_nil, :on, :if, :unless]
Instance Attribute Summary
Attributes inherited from Validator
#attribute_names, #options
Instance Method Summary
collapse
#value_included?
Methods inherited from Validator
#initialize, #validate
Instance Method Details
#message ⇒ Object
36
37
38
|
# File 'lib/aws/record/validators/exclusion.rb', line 36
def message
options[:message] || 'is reserved'
end
|
#setup(record_class) ⇒ Object
24
25
26
27
|
# File 'lib/aws/record/validators/exclusion.rb', line 24
def setup record_class
ensure_present(:in)
ensure_type(Enumerable, :in)
end
|
#validate_attribute(record, attribute_name, value_or_values) ⇒ Object
29
30
31
32
33
34
|
# File 'lib/aws/record/validators/exclusion.rb', line 29
def validate_attribute record, attribute_name, value_or_values
each_value(value_or_values) do |value|
included = value_included?(value)
record.errors.add(attribute_name, message) if included
end
end
|