Class CValidator
CValidator is the base class for all validators.
Child classes must implement the CValidator::validateAttribute()
method.
CValidator::createValidator()
to create a validator, the following aliases
are recognized as the corresponding built-in validator classes:
- required:
CRequiredValidator
- filter:
CFilterValidator
- match:
CRegularExpressionValidator
- email:
CEmailValidator
- url:
CUrlValidator
- unique:
CUniqueValidator
- compare:
CCompareValidator
- length:
CStringValidator
- in:
CRangeValidator
- numerical:
CNumberValidator
- captcha:
CCaptchaValidator
- type:
CTypeValidator
- file:
CFileValidator
- default:
CDefaultValueValidator
- exist:
CExistValidator
- boolean:
CBooleanValidator
- date:
CDateValidator
- safe:
CSafeValidator
- unsafe:
CUnsafeValidator
- CComponent
- CValidator
Direct known subclasses
CBooleanValidator, CCaptchaValidator, CNumberValidator, CRangeValidator, CRegularExpressionValidator, CRequiredValidator, CSafeValidator, CStringValidator, CTypeValidator, CUniqueValidator, CUnsafeValidator, CUrlValidator, CCompareValidator, ValidLinkValidator, X2Validator, CDateValidator, CDefaultValueValidator, CEmailValidator, CExistValidator, CFileValidator, CFilterValidator, CInlineValidatorIndirect known subclasses
ArrayValidator, ModuleModelNameValidator, RequiredIfNotSetValidator, X2ModelForeignKeyValidator, X2ModelUniqueIndexValidator, X2UrlValidatorPackage: system\validators
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/framework/validators/CValidator.php
abstract protected
|
#
validateAttribute(
Validates a single attribute. This method should be overridden by child classes. |
public static
|
#
createValidator( string $name,
Creates a validator object. |
public
|
|
public
string
|
#
clientValidateAttribute(
Returns the JavaScript needed for performing client-side validation. Do not
override this method if the validator does not support client-side validation.
Two predefined JavaScript variables can be used:
|
public
boolean
|
|
protected
|
|
protected
boolean
|
public static
array
|
$builtInValidators | array(
'required'=>'CRequiredValidator',
'filter'=>'CFilterValidator',
'match'=>'CRegularExpressionValidator',
'email'=>'CEmailValidator',
'url'=>'CUrlValidator',
'unique'=>'CUniqueValidator',
'compare'=>'CCompareValidator',
'length'=>'CStringValidator',
'in'=>'CRangeValidator',
'numerical'=>'CNumberValidator',
'captcha'=>'CCaptchaValidator',
'type'=>'CTypeValidator',
'file'=>'CFileValidator',
'default'=>'CDefaultValueValidator',
'exist'=>'CExistValidator',
'boolean'=>'CBooleanValidator',
'safe'=>'CSafeValidator',
'unsafe'=>'CUnsafeValidator',
'date'=>'CDateValidator',
) |
#
list of built-in validators (name=>class) |
public
array
|
$attributes |
|
#
list of attributes to be validated. |
public
string
|
$message |
|
#
the user-defined error message. Different validators may define various placeholders in the message that are to be replaced with actual values. All validators recognize "{attribute}" placeholder, which will be replaced with the label of the attribute. |
public
boolean
|
$skipOnError | false |
#
whether this validation rule should be skipped when there is already a validation error for the current attribute. Defaults to false. |
public
array
|
$on |
|
#
list of scenarios that the validator should be applied. Each array value refers to a scenario name with the same name as its array key. |
public
array
|
$except |
|
#
list of scenarios that the validator should not be applied to. Each array value refers to a scenario name with the same name as its array key. |
public
boolean
|
$safe | true |
#
whether attributes listed with this validator should be considered safe for massive assignment. Defaults to true. |
public
boolean
|
$enableClientValidation | true |
#
whether to perform client-side validation. Defaults to true. Please refer to
|