Validating Input

Validating Input

As a rule of thumb, you should never trust the data received from end users and should always validate it before putting it to good use.

Given a model populated with user inputs, you can validate the inputs by calling the yii\base\Model::validate() method. The method will return a boolean value indicating whether the validation succeeded or not. If not, you may get the error messages from the 登录查看完整内容