Also, there was just a typo in your original post.
'min:2|max5'
should have been 'min:2|max:5'
.
Notice the ":" for the "max" rule.
$this->validate($request,[
'input_field_name'=>'digits_between:2,5',
]);
Try this it will be work
Laravel min
and max
validation do not work properly with a numeric
rule validation. Instead of numeric, min and max
, Laravel provided a rule digits_between
.
$this->validate($request,[
'field_name'=>'digits_between:2,5',
]);
Source: Stackoverflow.com