Have you tried something like this?
'Player.*.MailingList' => 'required_if:Player.*.EmailAddress|in:Yes,No',
I imagine Laravel would substitute the * in all the validation components with the current index, not only the keys.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm writing a small app that submits booking requests for a fundraising event. The form submits an array of players, which is then validated. Each player may or may not have an email address. There is an option for each of the players to be subscribed to the organisation's mailing list.
How do I go about validating the mailing-list selection (select box values: Yes, No) so that it may only be Yes if the email address for that player is provided, using * notation?
I have thought about using sometimes, but I don't know how to target a specific player in the array.
These are the rules for the players:
'Player.*.FirstName' => 'required|between:2,30',
'Player.*.LastName' => 'required|between:2,30',
'Player.*.ContactNumber' => 'nullable|regex:/0\d{2}\s\d{3}\s\d{4}(?:\sext\.\s\d{1,5})?/',
'Player.*.EmailAddress' => 'nullable|email',
'Player.*.MailingList' => 'required|in:Yes,No', // This should only be Yes if the player's email is present
Many thanks!
Please or to participate in this conversation.