Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad request exception message format #195

Open
arifszn opened this issue Dec 24, 2021 · 1 comment
Open

Bad request exception message format #195

arifszn opened this issue Dec 24, 2021 · 1 comment

Comments

@arifszn
Copy link

arifszn commented Dec 24, 2021

Currently, the starter kit returns a bad request exception(400) message details in the following pattern.

"message": [
    "name must be a string",
    "name should not be empty",
    "email must be an email",
    "email should not be empty"
],

There is no specification of the field for which the error has occurred. Then how would the frontend know in which field the error message should be displayed? How about returning the error messages like this? Or any better format?

"message": {
    "name": [
        "name must be a string",
        "name should not be empty",
    ],
    "email": [
        "email must be an email",
        "email should not be empty",
    ]
}
@atiqaraj
Copy link

atiqaraj commented Feb 14, 2022

This format is more generic imo

{
   "messages":[
      {
         "key":"name",
         "errors":[
            "name must be a string",
            "name should not be empty"
         ]
      },
      {
         "key":"email",
         "errors":[
            "email must be an email",
            "email should not be empty"
         ]
      }
   ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants