File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -179,12 +179,13 @@ app = fastapi.FastAPI()
179179@app.get (" /return-http-422-on-async-validation-error" )
180180async def return_http_422_on_async_validation_error ():
181181 instance = SomethingModel(... )
182- with ensure_request_validation_errors():
182+ with ensure_request_validation_errors(" body " ): # use body as error location prefix
183183 await instance.model_async_validate()
184184```
185185
186186You may also use ` ensure_request_validation_errors ` to do additional validation on the request data using normal
187- pydantic validation and converting those ` ValidationError ` s to ` RequestValidationError ` s. 😉
187+ pydantic validation and converting those ` ValidationError ` s to ` RequestValidationError ` s. Use the ` prefix `
188+ parameter to mimic the FastAPI behaviour regarding using "body" for POST body data for example. 😉
188189
189190** Note:** When using FastAPI you should install ` pydantic-async-validation ` using
190191` pip install pydantic-async-validation[fastapi] ` to ensure FastAPI is installed in a compatible version.
You can’t perform that action at this time.
0 commit comments