Method: ActiveModel::EachValidator#validate
- Defined in:
- lib/active_model/validator.rb
permalink #validate(record) ⇒ Object
Performs validation on the supplied record. By default this will call validate_each
to determine validity therefore subclasses should override validate_each
with validation logic.
150 151 152 153 154 155 156 157 |
# File 'lib/active_model/validator.rb', line 150 def validate(record) attributes.each do |attribute| value = record.read_attribute_for_validation(attribute) next if (value.nil? && [:allow_nil]) || (value.blank? && [:allow_blank]) value = prepare_value_for_validation(value, record, attribute) validate_each(record, attribute, value) end end |