mirror of
https://github.com/dartdavros/chatballs.git
synced 2026-10-05 17:14:59 +03:00
15 lines
459 B
Python
15 lines
459 B
Python
from django.core.exceptions import ValidationError
|
|
from rest_framework.response import Response
|
|
|
|
|
|
def validation_error_response(error: ValidationError) -> Response:
|
|
if hasattr(error, "message_dict"):
|
|
detail = "; ".join(
|
|
message
|
|
for messages in error.message_dict.values()
|
|
for message in messages
|
|
)
|
|
else:
|
|
detail = "; ".join(error.messages)
|
|
return Response({"detail": detail}, status=400)
|