7 months ago

Customize $message when validation failed on `unique`?

Posted 7 months ago by tomspeak

I am building a JSON API and when creating a user, I have form request validation that declares

  'email' => [

When trying to create a user that already exists, I receive

{"message":"The given data was invalid.","errors":{"email":["The email has already been taken."]}}

This is a poor experience for the user on the front-end as I have it set up to render all message at the bottom of the form.

Ideally I would display An account already exists at the bottom of the form, not as the inline email field message.

How do I selectively override the message returned when using form request validation?


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