This method executes the validation rules applicable to the current [[scenario]].
The following criteria are used to determine whether a rule is currently applicable:
- the rule must be associated with the attributes relevant to the current scenario;
- the rules must be effective for the current scenario.
This method will call Model::beforeValidate and Model::afterValidate before and
after the actual validation, respectively. If Model::beforeValidate returns false,
the validation will be cancelled and Model::afterValidate will not be called.
Errors found during the validation can be retrieved via Model::getErrors,
Model::getFirstErrors and Model::getFirstError.
public validate ( array $attributeNames = null, boolean $clearErrors = true ) : boolean | ||
$attributeNames | array | list of attribute names that should be validated. If this parameter is empty, it means any attribute listed in the applicable validation rules should be validated. |
$clearErrors | boolean | whether to call [[clearErrors()]] before performing validation |
return | boolean | whether the validation is successful without any error. |