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

vincent15000's avatar

Validate request having one field required among three different fields ?

Hello,

To validate a form, I must have either nom or prenom or email.

If I set each field to required in my ContactRequest file, each one will be required. But I need only one required among the three.

How is it possible to set this validation rule ?

Thanks.

Vincent

0 likes
4 replies
senaranya's avatar
Level 10

You can use

nom => "required_without:prenom,email",
prenom => "required_without:nom,email",
email => "required_without:nom,prenom",

Or required_without_all, depending on your situation. Documentation here

vincent15000's avatar

Is it possible to set like this ?

nom => "required_without:prenom,email|nullable",
prenom => "required_without:nom,email|nullable",
email => "required_without:nom,prenom|nullable",
vincent15000's avatar

I just tried it ... it doesn't work (with or without nullable it doesn't work).

I have to use required_without_all ;).

Please or to participate in this conversation.