Class AWS::Record::Errors
In: lib/aws/record/errors.rb
Parent: Core::IndifferentHash

Methods

[]   []=   add   add_to_base   clear!   count   each   full_messages   on   size   to_a   to_hash  

Included Modules

Enumerable

Public Instance methods

Returns the errors for the atttibute in an array.

    errors.add(:name, 'may not be blank')
    errors.add(:name, 'must be less than 30 characters')
    errors[:name]
    #=> ['may not be blank', 'must be less than 30 characters']

@param [String,Symbol] attribute_name The name of the attribute to retnr

  errors for.  You can pass the string or symbol version.

@return [Array<String>] Returns the error messages for the given

  `attribute_name`.  If there are no errors on the attribute then
  an empty array is returned.

Adds an error message to the named attribute.

    errors.add(:name, 'may not be blank')
    errors.on(:name)
    #=> ['may not be blank']

If you want to add a general error message, then pass `:base` for `attribute_name`, or call {add_to_base}. @param [String,Symbol] attribute_name The name of the attribute

  that you are adding an error to.

@param [String] message (‘is invalid’) The error message (should

  not contain the attribute name).

@return [String] Returns the message.

add(attribute_name, message = 'is invalid')

Alias for #[]=

Adds a general error message (not associated with any particular attribute). @param [String] message (‘is invalid’) The error message (should

  not contain the attribute name).

@return [String] Returns the message.

Removes all error messages. @return [nil]

@return [Integer] Returns the number of error messages.

Yields once for each error message added.

An attribute_name may yield more than once if there are more than one errors associated with that attirbute.

@yield [attribute_name, error_message] @yieldparam [String] attribute_name The name of the attribute @yieldparam [String] error_message The error message associated the

  the named attribute.

Returns the errors prefixed by a humanized version of the attribute name.

    errors.add(:name, 'may not be blank')
    errors.full_messages
    #=> ['Name may not be blank']

@return [Array of Strings] Returns an array of error messages.

on(attribute_name)

Alias for #[]

size()

Alias for count

to_a()

Alias for full_messages

Returns a hash of of errors messages. Keys are attribute names and values are arrays of error messages.

    errors.add(:name, 'may not be blank')
    errors.to_hash
    #=> { 'name' => ['may not be blank'] }

Please note that the hash values are always arrays, even if there is only one error message for the attribute.

[Validate]