Method: PureValidator::ValidationErrors#each
- Defined in:
- lib/pure_validator/validation_errors.rb
#each ⇒ Object
Iterates through each error key, value pair in the error messages hash. Yields the attribute and the error for that attribute. If the attribute has more than one error message, yields once for each error message.
errors.add(:name, "can't be blank")
errors.each do |attribute, error|
# Will yield :name and "can't be blank"
end
errors.add(:name, "must be specified")
errors.each do |attribute, error|
# Will yield :name and "can't be blank"
# then yield :name and "must be specified"
end
87 88 89 90 91 |
# File 'lib/pure_validator/validation_errors.rb', line 87 def each .each_key do |attribute| self[attribute].each { |error| yield attribute, error } end end |