I would write a custom validation for this. Sounds like quite specific. Or change the format to not use an array in this way
transaction.in' =>
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi guys, I have the following request input in Laravel:
{
"date": "2022-07-07",
"remarks": "My First Transaction !",
"transactions": [
{
"item": 1,
"in": "54000"
},
{
"item": 2,
"out": "54000"
}
]
}
I want to validate the array transactions where one of the two field "in" or "out" is required ! So far I got to:
$rules = [
'date' => 'required|date',
'remarks' => 'required|string',
'transactions.*.item' => 'required|integer',
'transactions.*.in' =>'required_without:transactions.*.out',
'transactions.*.out' =>'required_without:transactions.*.in'
];
I am getting the following error: Undefined array key "out""
Please Let me know what am i missing ... !!!
Please or to participate in this conversation.