class ActiveModel::Validations::InclusionValidator
def check_validity!
def check_validity! raise ArgumentError, "An object with the method include? is required must be supplied as the " << ":in option of the configuration hash" unless options[:in].respond_to?(:include?) end
def validate_each(record, attribute, value)
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
def validate_each(record, attribute, value)
def validate_each(record, attribute, value) unless options[:in].include?(value) record.errors.add(attribute, :inclusion, options.except(:in).merge!(:value => value)) end end