13

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',

2 Answers 2

20

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'
11

in general case ,say, for a string with arbitrary characters:

'last_not_only_4_digits' => 'size:4'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.