I have 3 types of data to validate
- data in group
- single data
- single and data in group combined
This validation works for single data
$validator = Validator::make($request->all(), [
'tests.*.finding' => 'required',//works for single test
]);
Data sample for above
["tests"=>
[
0 => ["finding"=>""]
],
[
1 => ["finding"=>""]
]
]
And this validation works for data in group
$validator = Validator::make($request->all(), [
'tests.*.*.finding' => 'required',//works for group
]);
Data sample for above
["tests"=>
[
"A" =>[
[
0 => ["finding"=>""]
],
[
1 => ["finding"=>""]
]
],
"B" =>[
[
0 => ["finding"=>""]
],
[
1 => ["finding"=>""]
]
]
]
]
How to validate for single and data in group combined
Combined Data sample
["tests"=>
[
"A" =>[
[
0 => ["finding"=>""]
],
[
1 => ["finding"=>""]
]
]
],
[
0 => ["finding"=>""]
],
[
1 => ["finding"=>""]
]
]
Please help me to fix this, as 1st scenario always gives error for scenario second and vice versa.