0
votes

I have some rules in the model:

[['username', 'email', 'password', 'password_repeat'],'required', 'message' => 'Can not be blank'],
['username', 'string', 'min' => 2, 'max' => 255],
['password', 'string', 'min' => 6, 'max' => 255],

I set the message for checking if any of these fields were blank. But how can I set messages to check inputs length.

I've tried:

['username', 'string', 'min' => 2, 'max' => 255, 'message' => 'too few characters'] Yet it doesn't seem to be correct.

1

1 Answers

1
votes

You need to set the tooShort property, http://www.yiiframework.com/doc-2.0/yii-validators-stringvalidator.html#$tooShort-detail

['username', 'string', 'min' => 2, 'max' => 255, 'tooShort' => 'too few characters']