Method: PureValidator::ValidationErrors#add

Defined in:
lib/pure_validator/validation_errors.rb

#add(attribute, message) ⇒ Object

Adds message to the error messages on attribute. More than one error can be added to the same attribute

errors.add(:name, 'is invalid')
# => ["is invalid"]
errors.add(:name, 'must be implemented')
# => ["is invalid", "must be implemented"]

errors.messages
# => {:name=>["must be implemented", "is invalid"]}

If message is a proc, it will be called, allowing for things like Time.now to be used within an error.

errors.messages # => {}


181
182
183
# File 'lib/pure_validator/validation_errors.rb', line 181

def add(attribute, message)
  self[attribute] << message
end