Laravel is not validating the unique value (database)

Viewed 34

I am using Laravel 5.4 and want to validate unique alternate email.

$this->validate($request, [
    'alternate' => 'required',
                   'email',
                   'unique:users,alternate_email']);

// tried as well to specify db "unique:pgsql.users,alternate_email"
1 Answers

The value for your field key should be an array, something like:

$this->validate($request, [
    'alternate' => [
        'required',
        'email',
        'unique:users,alternate_email'
    ]
]);
Related