method

validate_each

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

nhance ยท Jul 5, 2011

In what appears to be a bug, there appears to be no way to use a custom error message when using this validator.