Skip to content
This repository has been archived by the owner on Mar 18, 2021. It is now read-only.

Can I customize the error handler messages? #824

Open
rafante opened this issue Apr 26, 2020 · 1 comment
Open

Can I customize the error handler messages? #824

rafante opened this issue Apr 26, 2020 · 1 comment

Comments

@rafante
Copy link

rafante commented Apr 26, 2020

If you have a controller saving a model that has some mandatory fields for example, username and the frontend send null for the username, if I don't treat the possibility of sending null value for the username, the api responds with:

{
   "error":"non_null_violation",
   "detail":"Offending Items: _usuario.username"
}

Can I customize it to be something like this?

{
   "error":"non_null_violation",
   "detail":"Campos inválidos: Nome de Usuário"
}

in my own language?

@Andreigr0
Copy link

Even better would be a possibility to customize response object, e.g. something like this:

[
 {
  "error": "username.required",
  "detail": "Имя пользователя должно быть заполнено"
 },
 {
  "error": "email.validation_error",
  "detail": "Email должен быть корректным"
 }
]

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

No branches or pull requests

2 participants