2

I have a laravel validation that needs to match one of the 3 regex's

 $validatedData = $request->validate([

        'BCH-address' => 'regex:/^([13][a-km-zA-HJ-NP-Z1-9]{25,34})/',
        'BCH-address' => 'regex:/^((bitcoincash:)?(q|p)[a-z0-9]{41})/',
        'BCH-address' => 'regex:/^((BITCOINCASH:)?(Q|P)[A-Z0-9]{41})$/',

    ]),

Is there a way to use a OR condition for the validation??

Tony Sawlwin
  • 146
  • 1
  • 19

1 Answers1

4

You can add rule https://laravel.com/docs/5.6/validation#using-rule-objects and there your logic,
or use closure https://laravel.com/docs/5.6/validation#using-closures
or make it as separate rule https://laravel.com/docs/5.6/validation#using-extensions

Davit Zeynalyan
  • 8,418
  • 5
  • 30
  • 55