Reference: Model rules validation

Comparing #13 with #14

Revision #14 was created by huanito huanito on May 4, 2011, 6:26:43 PM.

added date example for 1.1.7

Content

[...]
1. `allowEmpty`, whether the attribute value can be null or empty.
2. `format`, value format. Can be an array or a string. By default it's 'MM/dd/yyyy'. All other formats are described in [CDateTimeParser] API.
3. `timestampAttribute`, name of the attribute that will receive date parsing result. By default the value is null.
4. NOTE: The date validator was added in Yii **1.1.7** - it's not available prior to that

   Example of date rule ('allowEmpty' defaults to true);
 
   ~~~
 
   [php]
 
   array('org_datetime', 'date','format'=>'yyyy-M-d H:m:s'),
 
   ~~~
 
 
+ `default` : [CDefaultValueValidator], sets the attributes with the specified value. It does not do validation. Its existence is mainly to allow specifying attribute default values in a dynamic way.
1. `setOnEmpty`, whether to set the default value only when the attribute value is null or empty string.
2. `value`, the default value to be set to the specified attributes.

+ `email` : [CEmailValidator], validates that the attribute value is a valid email address.
1. `allowEmpty`, whether the attribute value can be null or empty.
[...]