hahahaha
hahahaha

Reputation: 1031

Check Numeric Length Laravel

I want to do validation checking on password in Laravel 4.2. I want the password only in numeric form and minimum length is 6. So I used as below:

'password'      => 'required|numeric|min:6'

Numeric checking is fine, but min:6 is not correct, as if I enter '000000', it return error 'password must be at least 6'. I want to ask is the numeric checking is check with the bytes size? How to check with length on numeric?

Upvotes: 0

Views: 829

Answers (1)

Ján Kyselica
Ján Kyselica

Reputation: 699

Rule digits_between is for you.

'password'      => 'required|numeric|digits_between:6,20'

See docs

If you don't want constraint for maximum length try this regex:

'password'      => 'required|regex:/^[0-9]{6,}$/'

Upvotes: 3

Related Questions