method
validate_each
v3.0.9 -
Show latest stable
- Class:
ActiveModel::Validations::InclusionValidator
validate_each(record, attribute, value)public
No documentation available.
# File activemodel/lib/active_model/validations/inclusion.rb, line 15
def validate_each(record, attribute, value)
included = if options[:in].is_a?(Range)
options[:in].cover?(value)
else
options[:in].include?(value)
end
unless included
record.errors.add(attribute, :inclusion, options.except(:in).merge!(:value => value))
end
end 1Note
No way to use custom message
In what appears to be a bug, there appears to be no way to use a custom error message when using this validator.