instance method
validate
Ruby on Rails 8.0.4
Since v3.0.20Signature
validate(record)
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.
Parameters
-
recordreq
Source
# File activemodel/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? && options[:allow_nil]) || (value.blank? && options[:allow_blank])
value = prepare_value_for_validation(value, record, attribute)
validate_each(record, attribute, value)
end
end
Defined in activemodel/lib/active_model/validator.rb line 150
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveModel::EachValidator