Replies: 1 comment
-
If it's a custom validation mechanism then it's a custom error message. fastapi is a framework using starlette and pydantic nothing else, if you do something else then code it. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So I see that the default functionality is that there is a handler that returns a json representation of the validation errors when a
RequestValidationError
is thrown, which is basically a pydanticValidationError
.What I'm wondering is, is there a neat way to explicitly raise a validation for a specific field and have it tie into that validation error response logic?
The use case being, I have standard typing based validation of incoming data, and then I use it to make a request to a 3rd party api which may result in failure / problems with fields. In that case I want to return the validation error in the same format that initial validation errors get returned in.
Is there anything more elegant than defining a custom exception, and a custom handler, and constructing a json response that mimics the standard functionality?
Is there maybe a simplified
RequestValidationError
subclass that is meant to be explicitly instantiated with error information?Related issue: #471
Beta Was this translation helpful? Give feedback.
All reactions