Class ActiveModel::EachValidator
In: lib/active_model/validator.rb
Parent: Validator

EachValidator is a validator which iterates through the attributes given in the options hash invoking the validate_each method passing in the record, attribute and value.

All Active Model validations are built on top of this validator.

Methods

Attributes

attributes  [R] 

Public Class methods

Returns a new validator instance. All options will be available via the options reader, however the :attributes option will be removed and instead be made available through the attributes reader.

Public Instance methods

Hook method that gets called by the initializer allowing verification that the arguments supplied are valid. You could for example raise an ArgumentError when invalid options are supplied.

Performs validation on the supplied record. By default this will call validates_each to determine validity therefore subclasses should override validates_each with validation logic.

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

[Validate]