Module | N::Validation::MetaLanguage |
In: |
lib/glue/validation.rb
|
Implements the Validation meta-language.
Validates the confirmation of String attributes.
validate_confirmation :password, :msg => ‘No confirmation‘
Validates the format of String attributes.
validate_format :name, :format => /$A*/, :msg => ‘My error’, :on => :create
Validates that the attributes are included in an enumeration.
validate_inclusion :sex, :in => %w{ Male Female }, :msg => ‘huh??’ validate_inclusion :age, :in => 5..99
Validates the length of String attributes.
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.
validate_value :, :msg => ‘No confirmation‘