Error validating current user and server
You may also override yii\validators\Validator::validate Value() instead of ) when attaching validator.
validating email addresses), you may call the validate() method of the desired validator, like the following: After validation, you can check if the validation succeeded or not by calling the has Errors() method, and then get the validation errors from the errors property, like you do with a normal model.
the validation of one attribute depends on the value of another attribute you can use the when property to define such conditions. The following examples shows how to trim the spaces in the inputs and turn empty inputs into nulls by using the trim and default core validators: You may also use the more general filter validator to perform more complex data filtering.
For example, If you also need to support client-side conditional validation, you should configure the when Client property which takes a string representing a Java Script function whose return value determines whether to apply the rule or not. As you can see, these validation rules do not really validate the inputs.
You may create inline validators or standalone validators.
An inline validator is one defined in terms of a model method or an anonymous function.
The signature of the method/function is: If an attribute fails the validation, the method/function should call yii\base\Model::add Error() to save the error message in the model so that it can be retrieved back later to present to end users.