123456789_123456789_123456789_123456789_123456789_

Class: ActiveModel::Validations::InclusionValidator

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: ActiveModel::EachValidator
Defined in: activemodel/lib/active_model/validations/inclusion.rb

Constant Summary

Clusivity - Included

ERROR_MESSAGE

Class Method Summary

::ActiveModel::EachValidator - Inherited

.new

Returns a new validator instance.

::ActiveModel::Validator - Inherited

.kind

Returns the kind of the validator.

.new

Accepts options that will be made available through the options reader.

Instance Attribute Summary

Instance Method Summary

Clusivity - Included

#check_validity!, #delimiter, #include?,
#inclusion_method

After Ruby 2.2, Range#include? on non-number-or-time-ish ranges checks all possible values in the range for equality, which is slower but more accurate.

ResolveValue - Included

::ActiveModel::EachValidator - Inherited

#check_validity!

Hook method that gets called by the initializer allowing verification that the arguments supplied are valid.

#validate

Performs validation on the supplied record.

#validate_each

Override this method in subclasses with the validation logic, adding errors to the records #errors array where necessary.

#prepare_value_for_validation

::ActiveModel::Validator - Inherited

#kind

Returns the kind for this validator.

#validate

Override this method in subclasses with validation logic, adding errors to the records #errors array where necessary.

Constructor Details

This class inherits a constructor from ActiveModel::EachValidator

Instance Method Details

#validate_each(record, attribute, value)

[ GitHub ]

  
# File 'activemodel/lib/active_model/validations/inclusion.rb', line 10

def validate_each(record, attribute, value)
  unless include?(record, value)
    record.errors.add(attribute, :inclusion, **options.except(:in, :within).merge!(value: value))
  end
end