Question, studying the documentation for Yii is not quite figured out with the validation of incoming data:

class InsertForm extends Model 

{

 public $author; public $message; public function rules() { return [ ['author', 'validateValue'], ['message', 'validateValue'], ]; } /** * @param $attribute * @param $params */ public function validateValue($attribute, $params) { if ((strlen($attribute)<=5)) { $this->addError($attribute, 'Минимальная длинна поля 5 символов'); } } 

}

Those. the length of incoming values ​​must start from 5 characters

    1 answer 1

     return [ ['author', 'string', 'min' => 5, 'max' => 255, 'message'=>'Минимальная длинна поля 5 символов, нС болСС 255'], ['message', 'string', 'min' => 5, 'max' => 255, 'message'=>'Минимальная длинна поля 5 символов, нС болСС 255'] ]; 
    • Thank you, but what if an empty value arrives? - KOTJlETA
    • Everything, I figured out, I need to add 'required', thanks again - KOTJlETA