Laravel Validation one of two fields must be filled

809 0 0 0

Last Updated : 2025-04-29 00:31:22

In this snippet I will provide a way of validation one filed of two fields that must be filled

If you want one of two fileds must be filled, just use required_without like this


$rules = array(
'Email' => 'required_without:QQ',
'QQ' => 'required_without:Email',
);

If you have more than two fields and want one of them to be required use this snippet


$rules = array(
'Email' => 'required_without_all:foo,bar,...',
);

Mahmoud Anwar

Mahmoud Anwar

Back End Developer with a passion for developing innovative web applications that expedite the efficiency and effectiveness of organizational success. Well-versed in technology and writing code to create systems that are reliable and user-friendly. Also has the proven ability to motivate, educate, and collaborate effectively to build web applications and effectively track changes. Confident communicator, strategic thinker, and innovative creator to develop software that is customized to meet a company’s organizational needs, highlight their core competencies, and further their success.