Module: Validation

### Home Classes Methods

### In Files

- lib/assistance/validation.rb

### Namespace

- MODULE Validation::ClassMethods
- CLASS Validation::Errors
- CLASS Validation::Generator

### Methods

- ::included
- #errors
- #valid?
- #validate

### 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

The Validations module provides validation capabilities as a mixin. When included into a class, it enhances the class with class and instance methods for defining validations and validating class instances.

The Validation emulates the validation capabilities of ActiveRecord, and provides methods for validating acceptance, confirmation, presence, format, length and numericality of attributes.

To use validations, you need to include the Validation module in your class:

    class MyClass
      include Validation
      validates_length_of :password, :minimum => 6
    end

### Public Class Methods

included(c) click to toggle source

Includes the Validation class methods into the including class.

    # File lib/assistance/validation.rb, line 18
    def self.included(c)
      c.extend ClassMethods
    end

### Public Instance Methods

errors() click to toggle source

Returns the validation errors associated with the object.

    # File lib/assistance/validation.rb, line 23
    def errors
      @errors ||= Errors.new
    end

valid?() click to toggle source

Validates the object and returns true if no errors are reported.

    # File lib/assistance/validation.rb, line 34
    def valid?
      validate
      errors.empty?
    end

validate() click to toggle source

Validates the object.

    # File lib/assistance/validation.rb, line 28
    def validate
      errors.clear
      self.class.validate(self)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.