Class: ActiveModel::BlockValidator
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
EachValidator ,
Validator
|
|
Instance Chain:
self,
EachValidator ,
Validator
|
|
Inherits: |
ActiveModel::EachValidator
|
Defined in: | activemodel/lib/active_model/validator.rb |
Overview
BlockValidator
is a special EachValidator
which receives a block on initialization and call this block for each attribute being validated. validates_each
uses this validator.
Class Method Summary
- .new(options, &block) ⇒ BlockValidator constructor
EachValidator
- Inherited
.new | Returns a new validator instance. |
Validator
- Inherited
Instance Attribute Summary
Instance Method Summary
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 |
#prepare_value_for_validation |
Validator
- Inherited
Constructor Details
.new(options, &block) ⇒ BlockValidator
# File 'activemodel/lib/active_model/validator.rb', line 180
def initialize(, &block) @block = block super end
Instance Method Details
#validate_each(record, attribute, value) (private)
[ GitHub ]# File 'activemodel/lib/active_model/validator.rb', line 186
def validate_each(record, attribute, value) @block.call(record, attribute, value) end