-
Notifications
You must be signed in to change notification settings - Fork 0
RailsModels
Tim edited this page Aug 11, 2015
·
7 revisions
#####Validation
Contained within Model..
validates_presence_of :<column>validates_numerically_of :<column>validates_uniqueness_of :<column>-
validates_confirmation_of :<column>same as other column e.g.. password -
validates_acceptance_of :<column>make sure value is true e.g.. acceptance check box -
validates_length_of :<column>, minimum: 3- length of field -
validates_format_of :<column> with: /regex/- check format with a regular expression -
validates_inclusion_of :age, in: 21..99- checks a value is within a range -
validates_exclusion_of :age, in: 0..21, message: "sorry you must be over 21"- is outside a range
or
validates :status, presence: true, length: { minimum:3 }