YII2 'max' => '11' rule not working

Hello guys,

I want to set a maximum number of characters for this field to 11.

Here is my rule:

[[‘field’], ‘number’, ‘max’ => ‘11’],

But even when the field is less than 11 i still get the error:

field must be no greater than 11.

Please what am i doing wrong.

Please provide more details:

  1. Some code for the model/form.
  2. Do you use AJAX validation or clientside validation?

You’re now validating a number, not the amount of characters.

Don’t you need [['field'], 'string', 'length' => [1, 11]], or [['field'], 'string', 'max' => 11],?