Laravel Input validation Between is not validate correctly

currently i’m facing some issue in laravel input validation where the validation rules for between seems like doesnt apply correctly. Below is my HTML code.

<input type="hidden" name="_token" value="{{ csrf_token() }}">
                
Thread Title :
Price :

What i’m trying to do is to validate the given price must be between 0 and 9999.99. I inspect element and remove the min=”0″ and try to submit with negative value says -1000, the system seems to accept the input. Below is my validator rules

$validator = Validator::make($request::all(),
            [
                'thread_title' => 'required|max:100',
                'thread_item_price' => 'between:0,9999.99'
            ],
            [
                'thread_title.required' => 'Please fill in thread title.',
                'thread_title.max' => 'Thread title has exceeded 100 characters.',
                'thread_item_price.required' => 'Price cannot be empty.',
                'thread_item_price.between' => 'Price must be equals to 0 or 9999.99.',
            ]);

        if ($validator->fails()) {
            return Redirect::back()
                ->withErrors($validator)
                ->withInput();
        };

Am i doing something wrong and make the validation failed?

Leave a comment