Skip to content

Commit c2cb026

Browse files
authored
Merge pull request #16 from yassun4dev/update_readme
Update: README.
2 parents 1ce89f8 + 798d8c9 commit c2cb026

File tree

7 files changed

+36
-10
lines changed

7 files changed

+36
-10
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ let s = SampleEnum::Named {
3434
assert!(s.validate().is_ok());
3535
```
3636

37+
## Feature Flags
38+
39+
- `toml` - provide serialization/deserialization in `toml` format.
40+
- `yaml` - provide serialization/deserialization in `yaml` format.
41+
- `i128` - support `i128`/`u128` type.
42+
- `flatten` - change formatting to flattened error messages ( [jsonschema](https://docs.rs/jsonschema/latest/jsonschema/) crate style).
43+
3744
## Validations
3845

3946
Serde Valid support standard validation based JSON Schema.
@@ -257,7 +264,9 @@ assert!(s.validate().is_ok());
257264
```
258265

259266
## Validation Errors Format
267+
260268
### Named Struct
269+
261270
Field errors are output to `properties`.
262271

263272
```rust
@@ -287,6 +296,7 @@ assert_eq!(
287296
```
288297

289298
### Unnamed Struct
299+
290300
Field errors are output to `items`. The key for `items` is guaranteed to be a string of positive numbers.
291301

292302
```rust
@@ -319,6 +329,7 @@ assert_eq!(
319329
```
320330

321331
### New Type
332+
322333
Field errors are output to `errors`.
323334

324335
```rust
@@ -342,6 +353,7 @@ assert_eq!(
342353
```
343354

344355
### Named Enum
356+
345357
Variant errors are output to `properties`.
346358

347359
```rust
@@ -378,6 +390,7 @@ assert_eq!(
378390
```
379391

380392
### Unnamed Enum
393+
381394
Variant errors are output to `items`. The key for `items` is guaranteed to be a string of positive numbers.
382395

383396
```rust
@@ -412,6 +425,7 @@ assert_eq!(
412425
```
413426

414427
### Newtype Enum
428+
415429
Variant errors are output to `errors`.
416430

417431
```rust

axum_serde_valid/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ schemars = "0.8"
2323

2424
### Feature Flags
2525

26-
- `jsonschema` - provides [jsonschema](https://github.com/Stranger6667/jsonschema-rs) validation.
26+
- `jsonschema` - provide [jsonschema](https://github.com/Stranger6667/jsonschema-rs) validation.
2727
- `aide` - support [aide](https://github.com/tamasfe/aide).
2828

2929
### Example

axum_serde_valid/src/json.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
22
//! A simple crate provides a drop-in replacement for [`axum::Json`]
3-
//! that uses [`jsonschema`] to validate requests schemas
4-
//! generated via [`schemars`].
3+
//! that uses [jsonschema](https://docs.rs/jsonschema/latest/jsonschema/) to validate requests schemas
4+
//! generated via [schemars](https://docs.rs/schemars/latest/schemars/).
55
//!
66
//! You might want to do this in order to provide a better
77
//! experience for your clients and not leak serde's error messages.

axum_serde_valid/src/query.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
22
//! A simple crate provides a drop-in replacement for [`axum::extract::Query`]
3-
//! that uses [`jsonschema`] to validate requests schemas
4-
//! generated via [`schemars`].
3+
//! that uses [jsonschema](https://docs.rs/jsonschema/latest/jsonschema/) to validate requests schemas
4+
//! generated via [schemars](https://docs.rs/schemars/latest/schemars/).
55
//!
66
//! You might want to do this in order to provide a better
77
//! experience for your clients and not leak serde's error messages.

axum_serde_valid/src/rejection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use serde_valid::flatten::IntoFlat;
44

55
use crate::json_pointer::JsonPointer;
66

7-
/// Rejection for [`Json`].
7+
/// Rejection for [`axum::Json`].
88
#[derive(Debug)]
99
pub enum Rejection {
1010
/// A rejection returned by [`axum::Json`].

serde_valid/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ let s = SampleEnum::Named {
3434
assert!(s.validate().is_ok());
3535
```
3636

37+
## Feature Flags
38+
39+
- `toml` - provide serialization/deserialization in `toml` format.
40+
- `yaml` - provide serialization/deserialization in `yaml` format.
41+
- `i128` - support `i128`/`u128` type.
42+
- `flatten` - change formatting to flattened error messages ( [jsonschema](https://docs.rs/jsonschema/latest/jsonschema/) crate style).
43+
3744
## Validations
3845

3946
Serde Valid support standard validation based JSON Schema.

serde_valid/src/lib.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,20 @@
3434
//! assert!(s.validate().is_ok());
3535
//! ```
3636
//!
37+
//! ## Feature Flags
38+
//!
39+
//! - `toml` - provide serialization/deserialization in `toml` format.
40+
//! - `yaml` - provide serialization/deserialization in `yaml` format.
41+
//! - `i128` - support `i128`/`u128` type.
42+
//! - `flatten` - change formatting to flattened error messages ( [jsonschema](https://docs.rs/jsonschema/latest/jsonschema/) crate style).
43+
//!
3744
//! ## Validations
3845
//!
3946
//! Serde Valid support standard validation based JSON Schema.
4047
//!
4148
//! | Type | Serde Valid(validate derive) | Serde Valid(validate trait) | Json Schema |
42-
//! | :-----: | :----------------------------------- |
43-
//! :----------------------------------------------------- |
44-
//! :-----------------------------------------------------------------------------------------------------
45-
//! | | String | `#[validate(max_length = 5)]` | [`ValidateMaxLength`](ValidateMaxLength) | [maxLength](https://json-schema.org/understanding-json-schema/reference/string.html#length) |
49+
//! | :-----: | :----------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------------------- |
50+
//! | String | `#[validate(max_length = 5)]` | [`ValidateMaxLength`](ValidateMaxLength) | [maxLength](https://json-schema.org/understanding-json-schema/reference/string.html#length) |
4651
//! | String | `#[validate(min_length = 5)]` | [`ValidateMinLength`](ValidateMinLength) | [minLength](https://json-schema.org/understanding-json-schema/reference/string.html#length) |
4752
//! | String | `#[validate(pattern = r"^\d{5}$")]` | [`ValidatePattern`](ValidatePattern) | [pattern](https://json-schema.org/understanding-json-schema/reference/string.html#regular-expressions) |
4853
//! | Numeric | `#[validate(maximum = 5)]` | [`ValidateMaximum`](ValidateMaximum) | [maximum](https://json-schema.org/understanding-json-schema/reference/numeric.html#range) |

0 commit comments

Comments
 (0)