-
Notifications
You must be signed in to change notification settings - Fork 30
Validations
Eustáquio Rangel edited this page Jun 6, 2013
·
8 revisions
Some validations are provided:
-
Presence (not empty):
User::validates("name" ,array("presence"=>true))
-
Regular expression:
User::validates("email",array("format" =>"^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$"))
-
Uniqueness:
User::validates("email",array("uniqueness"=>true))
-
Numericality:
User::validates("id",array("numericality"=>true))
You can check for an valid object using $user->isValid()
.
For multiple validations on the same attribute, just add a validates
line for each validation.