0

I have the ordinary unique validation

            'bank_program_id' => [
                'required',
                'integer',
                'exists:bank_programs,id',
                Rule::unique('bank_program_country', 'bank_program_id')
                    ->where('country', $this->input('country')),
            ],

The business logic says there can be one unique combination bank_program_id + country

This validation works well inside form request but I wanna test the validation request and use such code:

$validator = Validator::make($data, $request->rules());
and the validation rule does not prevent duplicates.
Please suggest how to adapt this code, thx in advance

vdkt
  • 11
  • 2
  • Not really clear what issue you are stuck at. Could you clarify a bit more? – Arun A S Jun 06 '23 at 12:15
  • The main goal is create `unique` validation for combination of several fields. I've done it via `->where('country', $this->input('country'))` but I can't test it, cause validator does not know about `input` – vdkt Jun 06 '23 at 12:26

0 Answers0