Difference between #4 and #5 of
Create your own Validation Rule

Revision #5 has been created by marcanuy on Oct 9, 2011, 12:33:20 AM with the memo:

added missing constants
« previous (#4) next (#6) »


Title unchanged

Create your own Validation Rule

Category unchanged


Yii version unchanged

Tags unchanged

validator, validation rules, model validation, create validator

Content changed

The easiest way to create a new validation rule is inside the model that is going to use it.

Let's say that you want to check if a user password is safe enough.
Usually you could achieve this result just by using the [CRegularExpressionValidator](http://www.yiiframework.com/doc/api/CRegularExpressionValidator) but for the sake of this guide let's pretend that validator does not exist.

first of all in your model
class you'll have to add two constants
const WEAK = 0;
const STRONG = 1;
then in your 
rules method you'll have to set the rule

58 0
Viewed: 212 646 times
Version: 1.1
Category: How-tos
Written by: nickcv
Last updated by: Gismo
Created on: Mar 31, 2011
Last updated: 5 years ago
Update Article


View all history