count

count() Instance Public methods Returns the number of error messages. person.errors.add(:name, "can't be blank") person.errors.count # => 1 person.errors.add(:name, "must be specified") person.errors.count # => 2

clear

clear() Instance Public methods Clear the error messages. person.errors.full_messages # => ["name cannot be nil"] person.errors.clear person.errors.full_messages # => []

blank?

blank?() Instance Public methods aliases empty? empty?

as_json

as_json(options=nil) Instance Public methods Returns a Hash that can be used as the JSON representation for this object. You can pass the :full_messages option. This determines if the json object should contain full messages or not (false by default). person.errors.as_json # => {:name=>["cannot be nil"]} person.errors.as_json(full_messages: true) # => {:name=>["name cannot be nil"]}

added?

added?(attribute, message = :invalid, options = {}) Instance Public methods Returns true if an error on the attribute with the given message is present, false otherwise. message is treated the same as for add. person.errors.add :name, :blank person.errors.added? :name, :blank # => true

add_on_empty

add_on_empty(attributes, options = {}) Instance Public methods Will add an error message to each of the attributes in attributes that is empty. person.errors.add_on_empty(:name) person.errors.messages # => {:name=>["can't be empty"]}

add_on_blank

add_on_blank(attributes, options = {}) Instance Public methods Will add an error message to each of the attributes in attributes that is blank (using Object#blank?). person.errors.add_on_blank(:name) person.errors.messages # => {:name=>["can't be blank"]}

add

add(attribute, message = :invalid, options = {}) Instance Public methods Adds message to the error messages on attribute. More than one error can be added to the same attribute. If no message is supplied, :invalid is assumed. person.errors.add(:name) # => ["is invalid"] person.errors.add(:name, 'must be implemented') # => ["is invalid", "must be implemented"] person.errors.messages # => {:name=>["must be implemented", "is invalid"]} If message is a symbol, it will be

[]=

[]=(attribute, error) Instance Public methods Adds to the supplied attribute the supplied error message. person.errors[:name] = "must be set" person.errors[:name] # => ['must be set']

[]

[](attribute) Instance Public methods When passed a symbol or a name of a method, returns an array of errors for the method. person.errors[:name] # => ["cannot be nil"] person.errors['name'] # => ["cannot be nil"]