Class: Validation::Errors

### Home Classes Methods

### In Files

- lib/assistance/validation.rb

### Parent

Object

### Methods

- ::new
- #[]
- #add
- #clear
- #empty?
- #full_messages
- #on

### Files

- CHANGELOG
- COPYING
- README

### Class/Module Index

Quicksearch

- Validation
- Validation::ClassMethods
- Validation::Errors
- Validation::Generator
- Assistance
- Assistance::TimeCalculations
- Inflector
- Inflector::Inflections
- Array
- ConnectionPool
- FalseClass
- NilClass
- Numeric
- Object
- SingleThreadedPool
- String
- TrueClass

No matching classes.

# Validation::Errors

Validation::Errors represents validation errors.

### Public Class Methods

new() click to toggle source

Initializes a new instance of validation errors.

    # File lib/assistance/validation.rb, line 42
    def initialize
      @errors = Hash.new {|h, k| h[k] = []}
    end

### Public Instance Methods

[](att) click to toggle source
Alias for: on
add(att, msg) click to toggle source

Adds an error for the given attribute.

    # File lib/assistance/validation.rb, line 63
    def add(att, msg)
      @errors[att] << msg
    end

clear() click to toggle source

Clears all errors.

    # File lib/assistance/validation.rb, line 52
    def clear
      @errors.clear
    end

empty?() click to toggle source

Returns true if no errors are stored.

    # File lib/assistance/validation.rb, line 47
    def empty?
      @errors.empty?
    end

full_messages() click to toggle source

Returns an array of fully-formatted error messages.

    # File lib/assistance/validation.rb, line 68
    def full_messages
      @errors.inject([]) do |m, kv| att, errors = *kv
        errors.each {|e| m << "#{att} #{e}"}
        m
      end
    end

on(att) click to toggle source

Returns the errors for the given attribute.

    # File lib/assistance/validation.rb, line 57
    def on(att)
      @errors[att]
    end

Also aliased as: []

[Validate]

Generated with the Darkfish Rdoc Generator 2.