CNumberValidator
CNumberValidator validates that the attribute value is a number.
Public Properties
Hide inherited properties
| Property | Type | Description | Defined By |
| allowEmpty |
boolean |
whether the attribute value can be null or empty. |
CNumberValidator |
| attributes |
array |
list of attributes to be validated. |
CValidator |
| builtInValidators |
array |
list of built-in validators (name=>class) |
CValidator |
| integerOnly |
boolean |
whether the attribute value can only be an integer. |
CNumberValidator |
| max |
integer|double |
upper limit of the number. |
CNumberValidator |
| message |
string |
the user-defined error message. |
CValidator |
| min |
integer|double |
lower limit of the number. |
CNumberValidator |
| 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 |
| tooBig |
string |
user-defined error message used when the value is too big. |
CNumberValidator |
| tooSmall |
string |
user-defined error message used when the value is too small. |
CNumberValidator |
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 boolean $integerOnly;
whether the attribute value can only be an integer. Defaults to false.
public integer|double $max;
upper limit of the number. Defaults to null, meaning no upper limit.
public integer|double $min;
lower limit of the number. Defaults to null, meaning no lower limit.
public string $tooBig;
user-defined error message used when the value is too big.
public string $tooSmall;
user-defined error message used when the value is too small.
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.