php - Laravel max Validator not working -


i'm new laravel.

could explain why max validator doesn't work expected in case?

$input = ["schoolseatstotal" => '2000']; $rules = ['schoolseatstotal'=>'max:300']; $validator = validator::make($input, $rules); $validator->fails(); //expected: true, actual: false.  

you have schoolseatstotal string. string data, max value corresponds number of characters. want validate integer instead.

so change

$input = ["schoolseatstotal" => '2000']; 

to

$input = ["schoolseatstotal" => 2000]; 

to make sure validating numbers - this:

$rules = ['schoolseatstotal'=>'numeric|max:300']; 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -