Difference between #21 and #25 of
Reference: Model rules validation

Revision #25 has been created by CedSha on Feb 4, 2013, 5:27:51 AM with the memo:

Add filter validation samples
« previous (#21) next (#26) »


Title unchanged

Reference: Model rules validation

Category unchanged


Yii version unchanged

Tags unchanged

Form validation, model, validation, reference, validation rules, validator

Content changed

### `filter` : [CFilterValidator]
Transforms the data being validated based on a filter.

1. **filter**, the filter method.

With custom function
public function keepProductCode($eanupc){
return ltrim(substr($eanupc,6,6),'0');
*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. 
### `in` : [CRangeValidator]
Validates that the attribute value is among the list (specified via range).
4. **strict**, whether the comparison is strict (both type and value must be the same). *(false)*

### `length` : [CStringValidator]
Validates that the attribute value is of certain length.
6. **tooSmall**, user-defined error message used when the value is too small.

    'tooSmall'=>'You must order at least 1 piece',
    'tooBig'=>'You cannot order more than 250 pieces at once'),
### `match` : [CRegularExpressionValidator]
Validates that the attribute value matches to the specified regular expression.

1. **allowEmpty**, whether the attribute value can be null or empty. *(true)*
2. **not**, whether to invert the validation logic. Since Yii 1.1.5. *(false)*
3. **pattern**, the regular expression to be matched with.
97 0
Viewed: 778 959 times
Version: 1.1
Category: How-tos
Written by: krillzip
Last updated by: Rodrigo
Created on: Nov 29, 2009
Last updated: 4 years ago
Update Article


View all history