Tanvir Ahmed
Tanvir Ahmed

Reputation: 1019

How to validate a number between a range in laravel 5.4?

I want to validate the percentage of my loan that needs to be between 1 to 100, but I can't. I read the laravel documentation about the lte and gte but it was not supported in laravel 5.4. here I tried like this but no luck

'percentage' => 'required|in:1,100',

Upvotes: 1

Views: 667

Answers (2)

Rahul
Rahul

Reputation: 18567

I think you just need to add between clause,

'percentage'=>'required|integer|between:1,100',

Should do it as per Laravel 5.4 doc.

As your field is percentage so there will be float values. For that, you can use,

'percentage'=>'required|numeric|between:0,100'

Upvotes: 1

SirMissAlot
SirMissAlot

Reputation: 130

Try

'percentage' => 'required|integer|between:1,100'

Upvotes: 0

Related Questions