Reputation: 351
Laravel minimum length validation for numbers not working, please find the following expressions
'country_code' => 'regex:/^.{2,4}$/',
'country_code' => 'bail|required|numeric',
i need to restrict 1 digit nubers including zero ex: (01,+1,00,99,999,......) are valid (0,+,1,......) are invalid
Upvotes: 0
Views: 539
Reputation: 163217
If the maximum number you want to match is 999, you might use an alternation to match either a plus followed by matching 1-3 digits or match 2-3 digits.
^(?:\+\d{1,3}|\d{2,3})$
Upvotes: 1