Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

validation on exact length of numeric field in laravel 5

I have numeric field i want to validate on exact fill 4 digits.

like: 1234, 4567,1245

but these invalid inputs: like: 123, 346, 45m6, 34567

what I am trying:

'last4digits'             => 'numeric|between:4,4',
like image 833
Ayman Hussein Avatar asked May 14 '15 18:05

Ayman Hussein


1 Answers

You are looking for the digits rule. From the docs:

The field under validation must be numeric and must have an exact length of value.

'last4digits' => 'digits:4'
like image 168
lukasgeiter Avatar answered Oct 16 '22 22:10

lukasgeiter