Reputation: 3857
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',
Upvotes: 15
Views: 14746
Reputation: 4151
in general case ,say, for a string with arbitrary characters:
'last_not_only_4_digits' => 'size:4'
Upvotes: 13
Reputation: 152890
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'
Upvotes: 26