How to you display such messages in your frontend? [modifying message structure] #895
Bishwas-py
started this conversation in
General
Replies: 1 comment 3 replies
-
this is how we massage things: @api.exception_handler(NinjaValidationError)
def validation_error(
request: HttpRequest, exc: NinjaValidationError
) -> HttpResponse:
out = defaultdict(list)
for e in exc.errors:
loc = e['loc']
if loc and loc[0] == 'body':
loc = loc[2:]
elif len(loc) > 1:
loc = loc[1:]
if '__root__' in loc:
loc = ['detail']
msg = e['msg']
out['.'.join(map(str, loc))].append(msg)
return api.create_response(request, out, status=400) Generates something that feels kinda similar to Django stock validation errors |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This error message looks so clumsy, how do you guys display such a message in your frontend? A SvelteKit example would be great
or, is there a way to change the message structure, to something simpler like:
Beta Was this translation helpful? Give feedback.
All reactions