add feature 422 and update version to 0.4.0

This commit is contained in:
gengteng
2023-08-01 12:55:40 +08:00
parent 91ce221dd3
commit 8da4d2519d
7 changed files with 28 additions and 10 deletions

View File

@@ -44,8 +44,11 @@ pub async fn get_page_by_json(
}
```
When validation errors occur, the extractor will automatically return 400 with validation errors as the HTTP message body.
For more usage examples, please refer to the `basic.rs` and `custom.rs` files in the `tests` directory.
## Features
`422`: Use `422 Unprocessable Entity` instead of `400 Bad Request` as the status code when validation fails.
`into_json`: When this feature is enabled, validation errors will be serialized into JSON format and returned as the HTTP body.