Reference: Model rules validation

Comparing #26 with #27

Revision #27 was created by François Gannaz François Gannaz on Feb 19, 2013, 8:19:26 AM.

fix bad code example (a method with no side effect should be static)

Content

[...]
1. **filter**, the filter method.

*Examples:*

- With
standarda custom function ```php array('mycode','filter','filter'=>'strtoupper'), ``` - With custom functionmethod ```php array('eanupc','filter','filter'=>array($this,'keepProductCode')), array('eanupc','filter','filter'=>array(self,'formatProductCode')),
 
... public function keepProductCode($eanupccode){ // return ltrim(substr($eanupc,6,6),'0');s a new value (uses $this) ...
 
}
 
static public function formatProductCode($code){
 
// returns a new value (cannot use $this) ...

}
```
*NOTE:* The filter validator maybe use with other validators for the same attribute. In this case one must pay attention to the order of the validators list as the filter validator will change the attribute value.
[...]