xtremer360
6 months ago

Array Validation Rules Based off Sizes

Posted 6 months ago by xtremer360

I have two arrays in my request.

Array1 is required if array2 has a size of 1 or 0. If array2 has 0 in its size then array1 must have at least 3 in its size. If array2 has 1 as its size then array1 must have at least 1 as its size.

For array2 is required if array1 has a size of less than 3. If array1 has a size of 0 then array2 must have a size of 2. If array1 has a size of 1 or 2 then array2 must have a minimum size of 1.

'array1' => ['required', 'array', 'size:2'],
'array1.*' => ['bail', 'integer', new CanJoinTeam],
'array2' => ['required', 'array', 'size:2'],
'array2.*' => ['bail', 'integer', new CanJoinTeam,

Please sign in or create an account to participate in this conversation.