Skip to main content
Laravel

Laravel Validation Rules

By June 16, 2021No Comments

Two out of three fields required

1
2
3
4
5
6
7
8
        $rules = array(
            'title' => 'required',
// If any one of the field is not present from the other two fields. Makes the field being valided as required.
            'issue_letter' => Rule::requiredIf(!$request->call_issue || !$request->twitter_issue),
            'call_issue' => Rule::requiredIf(!$request->issue_letter || !$request->twitter_issue),
            'twitter_issue' => Rule::requiredIf(!$request->issue_letter || !$request->call_issue),
            'slug' => 'required'
        );