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

HurairiDz's avatar

Array Validation At Least 1 Item & Item must be size of 12

Hello i would like some pointers on validate my use case here.

"nric_no" => array:3 [▼ 1 => "123456789011" 2 => "9231" 3 => null ]

How can i validate only 1 item is required out of the default 3 but the item is the array must be size of 12 characters.

$request->validate([
            'name'=>'required|array|min:1',
            'email'=>'required|array|min:1',
            'nric_no'=>'required|array', 
            'nric_no.*' => 'nullable', 
            'nric_no.1' => 'required',
            'designation'=>'required|array|min:1',
            'phone_no'=>'required',
            'sku'=>'required',
        ],
0 likes
2 replies
krisi_gjika's avatar
'nric_no'   => 'required|array|min:1',
'nric_no.*' => 'required|digits:12',
HurairiDz's avatar

i got it this works well !

'nric_no'=>'required|array|min:1', 'nric_no' => 'required|array', 'nric_no.*' => 'nullable|string|size:12', 'nric_no.1' => 'required|string|size:12',

Please or to participate in this conversation.