Revision #2 was created by krillzip on Nov 29, 2009, 1:46:12 PM.
Added the "Validation rules reference" section, (temporarly saving)
Content
This is a reference to be used for Model rule validation. The documentation and is compiled from the Yii documentation and code. The purpose is to have all the information gathered in one place instead of scattered. This reference is not an intro.
Applys to Yii: 1.0.10
[...]
The [CModel](/doc/api/1.0.10/CModel) class uses a method named [rules](/doc/api/1.0.10/CModel#rules-detail) to return an array with the rules for validation.
To be continued
## Validation rules reference
TODO: Write all references
## Selected readings
[The Definitive Guide to Yii: Working with Forms - Creating Model](/doc/guide/form.model)<br />
[Yii PHP Framework Class Reference - C
```php
public function rules()
The code above is an example of what the [rules()](/doc/api/CModel#rules-detail) function may look like. The arrays in the main array each one sets a rule of validation.
### Choise of validators
Yii will look for validators in the specifik order:
1. A method in the model class with the same name as the validator specified.
2. A builtin validator in Yii that extends the CValidator class.
3. A path/alias to a home made CValidator class that is not built in.
### Scenarios
TODO: Write shortly about scenarios.
### Standard parameters
```php
array(
'attribute list',
'validator name',
'on'=>'scenario name',
'message'=>'The attribute didn\'t validate!',
...validation parameters...
);
```
+ <code>attribute list</code>: specifies the attributes (separated by commas) to be validated;
+ <code>validator name</code>: specifies the validator to be used.
+ <code>on</code>: this specifies the scenarios when the validation rule should be performed. Separate different scenarios with commas. If this option is not set, the rule will be applied in any scenario.
+ <code>message</code>: Error message if validation fails.
+ <code>...validation parameters...</code>: any number of extra parameters to be used by the specified validator.