Form Validation Rules for minimum value of integer in a field

I wanna check a input field with the bellow given criteria:

  1. Only accept integer value

  2. length minimum 1 maximum 3

  3. value minimum 5

array('roll', 'numerical', 'integerOnly'=>true),

      array('roll', 'length', 'min'=>1, 'max'=>3),

The above mentioned code satisfy first 2 criteria.

How to satisfy 3rd criteria.

Please Help.

Thanks in advance

You forgot the min in the first rule.

For CNumberValidator (first rule) means min the lower limit of the number.

For CStringValidator (second rule) means min the minimum length.

array('roll', 'numerical', 'integerOnly'=>true, 'min'=>5),

array('roll', 'length', 'min'=>1, 'max'=>3),

1 Like


Thank you so much.

It works fine.

Is there a max CNumberValidator ?