Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Shivamyadav's avatar

Employee form validaton? (Date, and mobile number)

my validation rules

'dob' => 'required',
'mobile' => 'required',

1st : I want something like that employee age must be 18 or greater than 18 years . 2nd : I want to add a mobile number validation for every country and with country code.

0 likes
1 reply
tisuchi's avatar
tisuchi
Best Answer
Level 70

@shivamyadav

1st : I want something like that employee age must be 18 or greater than 18 years

You can do it easily by:

'dob' => [
    'required',
    'date',
    'before_or_equal:' . now()->subYears(18)->format('Y-m-d')
],

2nd : I want to add a mobile number validation for every country and with country code.

You need to depend on the package. For example:

Then you can easily like this:

'mobile' => [
    'required',
    'phone:AUTO',  // AUTO will detect the country from the input or you can specify specific countries like 'phone:US,IN'
],
3 likes

Please or to participate in this conversation.