Validation in Rails

In the following way you can perform validation on rails,

validates_presence_of :name, :message=>’Provide Organization Name’

validates_uniqueness_of :name,:message=>’Name already used.Provide different name’

validates_length_of :name, :maximum => 35

validates_length_of :name,    :within => 6..32,:too_short=>”Name must have at least 6 characters”,:too_long=>”Name must not exceed 32 characters”

validates_format_of :email,:with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i,:message => ‘Email must be valid’

validates_numericality_of :contact_no,:message=>”Please enter numbers only”

validates_date :date_of_birth

validates_time :current_time – validate value as time only i.e. ’12:20pm’

validates_datetime :created_at – validate value as a full date and time