Class: ActiveRecord::Validations::LengthValidator

Inherits:
ActiveModel::Validations::LengthValidator show all
Defined in:
activerecord/lib/active_record/validations/length.rb

Overview

:nodoc:

Constant Summary

Constants inherited from ActiveModel::Validations::LengthValidator

ActiveModel::Validations::LengthValidator::CHECKS, ActiveModel::Validations::LengthValidator::MESSAGES, ActiveModel::Validations::LengthValidator::RESERVED_OPTIONS

Instance Attribute Summary

Attributes inherited from ActiveModel::EachValidator

#attributes

Attributes inherited from ActiveModel::Validator

#options

Instance Method Summary collapse

Methods inherited from ActiveModel::Validations::LengthValidator

#check_validity!, #initialize

Methods included from ActiveModel::Validations::ResolveValue

#resolve_value

Methods inherited from ActiveModel::EachValidator

#check_validity!, #initialize, #validate

Methods inherited from ActiveModel::Validator

#initialize, kind, #kind, #validate

Constructor Details

This class inherits a constructor from ActiveModel::Validations::LengthValidator

Instance Method Details

#validate_each(record, attribute, association_or_value) ⇒ Object



6
7
8
9
10
11
# File 'activerecord/lib/active_record/validations/length.rb', line 6

def validate_each(record, attribute, association_or_value)
  if association_or_value.respond_to?(:loaded?) && association_or_value.loaded?
    association_or_value = association_or_value.target.reject(&:marked_for_destruction?)
  end
  super
end