class AWS::Record::Errors

def [] attribute_name

Returns:
  • (Array) - Returns the error messages for the given

Parameters:
  • attribute_name (String, Symbol) -- The name of the attribute to retnr
def [] attribute_name
  super(attribute_name) || []
end

def []= attribute_name, message = 'is invalid'

Returns:
  • (String) - Returns the message.

Parameters:
  • message (String) -- ('is invalid') The error message (should
  • attribute_name (String, Symbol) -- The name of the attribute
def []= attribute_name, message = 'is invalid'
  if has_key?(attribute_name)
    self[attribute_name] << message
  else
    super(attribute_name, [message])
  end
  self[attribute_name]
end

def add_to_base message

Returns:
  • (String) - Returns the message.

Parameters:
  • message (String) -- ('is invalid') The error message (should
def add_to_base message
  add(:base, message)
end

def clear!

Returns:
  • (nil) -
def clear!
  keys.each do |key|
    delete(key)
  end
  nil
end

def count

Returns:
  • (Integer) - Returns the number of error messages.
def count
  values.flatten.length
end

def each &block

Other tags:
    Yieldparam: error_message - The error message associated the
    Yieldparam: attribute_name - The name of the attribute

Other tags:
    Yield: -
def each &block
  super do |attribute_name, error_messages|
    error_messages.each do |error_message|
      yield(attribute_name, error_message)
    end
  end
end

def full_messages

Returns:
  • (Array of Strings) - Returns an array of error messages.
def full_messages
  messages = []
  each do |attr_name, error_message|
    messages << case attr_name
    when 'base' then error_message.dup
    else "#{attr_name.capitalize.gsub(/_/, ' ')} #{error_message}"
    end
  end
  messages
end

def to_hash

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

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

and values are arrays of error messages.
Returns a hash of of errors messages. Keys are attribute names
def to_hash
  hash = {}
  each do |attr_name, message|
    hash[attr_name] ||= []
    hash[attr_name] << message.dup
  end
  hash
end