boolean: CBooleanValidator
Validates that the attribute value is either trueValue or falseValue.
- trueValue, the value representing true status. Defaults to '1'
- falseValue, the value representing false status. Defaults to '0'
- strict, when this is true, the attribute value and type must both match those of {trueValue} or {falseValue}. Defaults to false, meaning only the value needs to be matched.
- allowEmpty, whether the attribute value can be null or empty. Defaults to true. Example:
array('name', 'boolean',
'allowEmpty'=>false,
'trueValue'=> 'Tuan',
'falseValue'=>'Tai',
'message'=>'The value must be "Tuan" or "Tai" and not empty',
)
captcha: CCaptchaValidator
Validates that the attribute value is the same as the verification code displayed in the CAPTCHA.
- allowEmpty, whether the attribute value can be null or empty. Defaults to false, meaning the attribute is invalid if it is empty.
- caseSensitive, whether the comparison is case sensitive. Defaults to false
- captchaAction, string ID of the action that renders the CAPTCHA image. Defaults to 'captcha', meaning the 'captcha' action declared in the current controller. This can also be a route consisting of controller ID and action ID. Example
array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements())
Full example about captcha in here
compare: CCompareValidator
Compares the specified attribute value with another value and validates if they are equal.
- allowEmpty, whether the attribute value can be null or empty. Defaults to false
- compareAttribute, the name of the attribute to be compared with
- compareValue, the constant value to be compared with
- strict, whether the comparison is strict (both value and type must be the same.). Defaults to false.
- operator, the operator for comparison. Defaults to '=' '=' or '==', '!=', '>', '>=', '<', '<=' Example
array ('usernameA', 'compare', 'compareValue' => '10', 'operator' => '>=', 'message' => 'must be greater than 10'),
array ('usernameB', 'compare', 'compareAttribute' => 'usernameC', 'operator’ => '>', 'message' => 'must be greater than usernameC'),
date: CDateValidator
Validates that the attribute value is a valid date, time or datetime.
- allowEmpty, whether the attribute value can be null or empty. Defaults to true
- format, the format pattern that the date value should follow. This can be either a string or an array representing multiple formats. Defaults to 'MM/dd/yyyy'. Please see CDateTimeParser for details about how to specify a date format.
- timestampAttribute, the name of the attribute to receive the parsing result. When this property is not null and the validation is successful, the named attribute will receive the parsing result.