Class: ActiveModel::Validations::ExclusionValidator

Inherits:
EachValidator show all
Includes:
Clusivity
Defined in:
activemodel/lib/active_model/validations/exclusion.rb

Overview

:nodoc:

Constant Summary

Constants included from Clusivity

Clusivity::ERROR_MESSAGE

Instance Attribute Summary

Attributes inherited from EachValidator

#attributes

Attributes inherited from ActiveModel::Validator

#options

Instance Method Summary collapse

Methods included from Clusivity

#check_validity!

Methods included from ResolveValue

#resolve_value

Methods inherited from EachValidator

#check_validity!, #initialize, #validate

Methods inherited from ActiveModel::Validator

#initialize, kind, #kind, #validate

Constructor Details

This class inherits a constructor from ActiveModel::EachValidator

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



10
11
12
13
14
# File 'activemodel/lib/active_model/validations/exclusion.rb', line 10

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