CUniqueValidator
CUniqueValidator validates that the attribute value is unique in the corresponding database table.
Public Properties
Hide inherited properties
| Property | Type | Description | Defined By |
| allowEmpty |
boolean |
whether the attribute value can be null or empty. |
CUniqueValidator |
| attributeName |
string |
the ActiveRecord class attribute name that should be
used to look for the attribute value being validated. |
CUniqueValidator |
| attributes |
array |
list of attributes to be validated. |
CValidator |
| builtInValidators |
array |
list of built-in validators (name=>class) |
CValidator |
| caseSensitive |
boolean |
whether the comparison is case sensitive. |
CUniqueValidator |
| className |
string |
the ActiveRecord class name that should be used to
look for the attribute value being validated. |
CUniqueValidator |
| criteria |
array |
additional query criteria. |
CUniqueValidator |
| message |
string |
the user-defined error message. |
CValidator |
| on |
array |
list of scenarios that the validator should be applied. |
CValidator |
| skipOnError |
boolean |
whether this validation rule should be skipped if when there is already a validation
error for the current attribute. |
CValidator |
Property Details
public boolean $allowEmpty;
whether the attribute value can be null or empty. Defaults to true,
meaning that if the attribute is empty, it is considered valid.
public string $attributeName;
the ActiveRecord class attribute name that should be
used to look for the attribute value being validated. Defaults to null,
meaning using the name of the attribute being validated.
public boolean $caseSensitive;
whether the comparison is case sensitive. Defaults to true.
Note, by setting it to false, you are assuming the attribute type is string.
public string $className;
the ActiveRecord class name that should be used to
look for the attribute value being validated. Defaults to null, meaning using
the class of the object currently being validated.
You may use path alias to reference a class name here.
public array $criteria;
additional query criteria. This will be combined with the condition
that checks if the attribute value exists in the corresponding table column.
This array will be used to instantiate a CDbCriteria object.
Method Details
protected void validateAttribute( CModel $object, string $attribute)
|
| $object |
CModel |
the object being validated |
| $attribute |
string |
the attribute being validated |
Validates the attribute of the object.
If there is any error, the error message is added to the object.