Ruby On Rails

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… Continue reading Validation in Rails