wizo
310
5
Laravel

Validation with two the same rules and different error messages

Posted 2 years ago by wizo

If I have the following rule:

        $this->validate($request, [
            'email' => [
                'required',
                'exists:users,email',
                Rule::exists('users', 'email')->where(function ($query)  {
                    $query->where('email_verified', 1);
                }),
            ],
            'password' => 'required',
        ], [
          'email.exists' => 'Message 1',
          'email.exists' => 'Message 2',
        ], []);

How can I specify two different messages for the exists rule.

Please sign in or create an account to participate in this conversation.