Module N::Validation::MetaLanguage
In: lib/glue/validation.rb

MetaLanguage

Implements the Validation meta-language.

Methods

Public Instance methods

Validates the confirmation of String attributes.

Example

validate_confirmation :password, :msg => ‘No confirmation‘

Validates the format of String attributes.

Example

validate_format :name, :format => /$A*/, :msg => ‘My error’, :on => :create

Validates that the attributes are included in an enumeration.

Example

validate_inclusion :sex, :in => %w{ Male Female }, :msg => ‘huh??’ validate_inclusion :age, :in => 5..99

Validates the length of String attributes.

Example

validate_length :name, :max => 30, :msg => ‘Too long’ validate_length :name, :min => 2, :msg => ‘Too sort’ validate_length :name, :range => 2..30 validate_length :name, :length => 15, :msg => ‘Name should be %d chars long‘

Validates that the attributes have a values, ie they are neither nil or empty.

Example

validate_value :, :msg => ‘No confirmation‘

[Validate]