Skip to content

Commit 5ad33ef

Browse files
committed
docs: update new format.
1 parent 0e02375 commit 5ad33ef

File tree

4 files changed

+45
-45
lines changed

4 files changed

+45
-45
lines changed

serde_valid/README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,22 @@ assert!(s.validate().is_ok());
4646

4747
Serde Valid support standard validation based JSON Schema.
4848

49-
| Type | Serde Valid (validate derive) | Serde Valid (validate trait) | JSON Schema |
50-
| :-----: | :----------------------------------- | :--------------------------- | :-------------------------------------------------------------------------------------------- |
51-
| String | `#[validate(max_length = 5)]` | [`ValidateMaxLength`] | [maxLength](https://json-schema.org/understanding-json-schema/reference/string#length) |
52-
| String | `#[validate(min_length = 5)]` | [`ValidateMinLength`] | [minLength](https://json-schema.org/understanding-json-schema/reference/string#length) |
53-
| String | `#[validate(pattern = r"^\d{5}$")]` | [`ValidatePattern`] | [pattern](https://json-schema.org/understanding-json-schema/reference/string#regexp) |
54-
| Numeric | `#[validate(maximum = 5)]` | [`ValidateMaximum`] | [maximum](https://json-schema.org/understanding-json-schema/reference/numeric#range) |
55-
| Numeric | `#[validate(minimum = 5)]` | [`ValidateMinimum`] | [minimum](https://json-schema.org/understanding-json-schema/reference/numeric#range) |
56-
| Numeric | `#[validate(exclusive_maximum = 5)]` | [`ValidateExclusiveMaximum`] | [exclusiveMaximum](https://json-schema.org/understanding-json-schema/reference/numeric#range) |
57-
| Numeric | `#[validate(exclusive_minimum = 5)]` | [`ValidateExclusiveMinimum`] | [exclusiveMinimum](https://json-schema.org/understanding-json-schema/reference/numeric#range) |
58-
| Numeric | `#[validate(multiple_of = 5)]` | [`ValidateMultipleOf`] | [multipleOf](https://json-schema.org/understanding-json-schema/reference/numeric#multiples) |
59-
| Object | `#[validate(max_properties = 5)]` | [`ValidateMaxProperties`] | [maxProperties](https://json-schema.org/understanding-json-schema/reference/object#size) |
60-
| Object | `#[validate(min_properties = 5)]` | [`ValidateMinProperties`] | [minProperties](https://json-schema.org/understanding-json-schema/reference/object#size) |
61-
| Array | `#[validate(max_items = 5)]` | [`ValidateMaxItems`] | [maxItems](https://json-schema.org/understanding-json-schema/reference/array#length) |
62-
| Array | `#[validate(min_items = 5)]` | [`ValidateMinItems`] | [minItems](https://json-schema.org/understanding-json-schema/reference/array#length) |
63-
| Array | `#[validate(unique_items)]` | [`ValidateUniqueItems`] | [uniqueItems](https://json-schema.org/understanding-json-schema/reference/array#uniqueItems) |
64-
| Generic | `#[validate(enumerate(5, 10, 15))]` | [`ValidateEnumerate`] | [enum](https://json-schema.org/understanding-json-schema/reference/enum) |
49+
| Type | Serde Valid (validate derive) | Serde Valid (validate trait) | JSON Schema |
50+
| :-----: | :------------------------------------- | :--------------------------- | :-------------------------------------------------------------------------------------------- |
51+
| String | `#[validate(max_length = 5)]` | [`ValidateMaxLength`] | [maxLength](https://json-schema.org/understanding-json-schema/reference/string#length) |
52+
| String | `#[validate(min_length = 5)]` | [`ValidateMinLength`] | [minLength](https://json-schema.org/understanding-json-schema/reference/string#length) |
53+
| String | `#[validate(pattern = r"^\d{5}$")]` | [`ValidatePattern`] | [pattern](https://json-schema.org/understanding-json-schema/reference/string#regexp) |
54+
| Numeric | `#[validate(maximum = 5)]` | [`ValidateMaximum`] | [maximum](https://json-schema.org/understanding-json-schema/reference/numeric#range) |
55+
| Numeric | `#[validate(minimum = 5)]` | [`ValidateMinimum`] | [minimum](https://json-schema.org/understanding-json-schema/reference/numeric#range) |
56+
| Numeric | `#[validate(exclusive_maximum = 5)]` | [`ValidateExclusiveMaximum`] | [exclusiveMaximum](https://json-schema.org/understanding-json-schema/reference/numeric#range) |
57+
| Numeric | `#[validate(exclusive_minimum = 5)]` | [`ValidateExclusiveMinimum`] | [exclusiveMinimum](https://json-schema.org/understanding-json-schema/reference/numeric#range) |
58+
| Numeric | `#[validate(multiple_of = 5)]` | [`ValidateMultipleOf`] | [multipleOf](https://json-schema.org/understanding-json-schema/reference/numeric#multiples) |
59+
| Object | `#[validate(max_properties = 5)]` | [`ValidateMaxProperties`] | [maxProperties](https://json-schema.org/understanding-json-schema/reference/object#size) |
60+
| Object | `#[validate(min_properties = 5)]` | [`ValidateMinProperties`] | [minProperties](https://json-schema.org/understanding-json-schema/reference/object#size) |
61+
| Array | `#[validate(max_items = 5)]` | [`ValidateMaxItems`] | [maxItems](https://json-schema.org/understanding-json-schema/reference/array#length) |
62+
| Array | `#[validate(min_items = 5)]` | [`ValidateMinItems`] | [minItems](https://json-schema.org/understanding-json-schema/reference/array#length) |
63+
| Array | `#[validate(unique_items)]` | [`ValidateUniqueItems`] | [uniqueItems](https://json-schema.org/understanding-json-schema/reference/array#uniqueItems) |
64+
| Generic | `#[validate(enumerate = [5, 10, 15])]` | [`ValidateEnumerate`] | [enum](https://json-schema.org/understanding-json-schema/reference/enum) |
6565

6666
In addition, [serde_valid::utils][module@crate::utils] provides a type of validation not described in the JSON schema specification.
6767

serde_valid/src/lib.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,22 @@
4646
//!
4747
//! Serde Valid support standard validation based JSON Schema.
4848
//!
49-
//! | Type | Serde Valid (validate derive) | Serde Valid (validate trait) | JSON Schema |
50-
//! | :-----: | :----------------------------------- | :--------------------------- | :-------------------------------------------------------------------------------------------- |
51-
//! | String | `#[validate(max_length = 5)]` | [`ValidateMaxLength`] | [maxLength](https://json-schema.org/understanding-json-schema/reference/string#length) |
52-
//! | String | `#[validate(min_length = 5)]` | [`ValidateMinLength`] | [minLength](https://json-schema.org/understanding-json-schema/reference/string#length) |
53-
//! | String | `#[validate(pattern = r"^\d{5}$")]` | [`ValidatePattern`] | [pattern](https://json-schema.org/understanding-json-schema/reference/string#regexp) |
54-
//! | Numeric | `#[validate(maximum = 5)]` | [`ValidateMaximum`] | [maximum](https://json-schema.org/understanding-json-schema/reference/numeric#range) |
55-
//! | Numeric | `#[validate(minimum = 5)]` | [`ValidateMinimum`] | [minimum](https://json-schema.org/understanding-json-schema/reference/numeric#range) |
56-
//! | Numeric | `#[validate(exclusive_maximum = 5)]` | [`ValidateExclusiveMaximum`] | [exclusiveMaximum](https://json-schema.org/understanding-json-schema/reference/numeric#range) |
57-
//! | Numeric | `#[validate(exclusive_minimum = 5)]` | [`ValidateExclusiveMinimum`] | [exclusiveMinimum](https://json-schema.org/understanding-json-schema/reference/numeric#range) |
58-
//! | Numeric | `#[validate(multiple_of = 5)]` | [`ValidateMultipleOf`] | [multipleOf](https://json-schema.org/understanding-json-schema/reference/numeric#multiples) |
59-
//! | Object | `#[validate(max_properties = 5)]` | [`ValidateMaxProperties`] | [maxProperties](https://json-schema.org/understanding-json-schema/reference/object#size) |
60-
//! | Object | `#[validate(min_properties = 5)]` | [`ValidateMinProperties`] | [minProperties](https://json-schema.org/understanding-json-schema/reference/object#size) |
61-
//! | Array | `#[validate(max_items = 5)]` | [`ValidateMaxItems`] | [maxItems](https://json-schema.org/understanding-json-schema/reference/array#length) |
62-
//! | Array | `#[validate(min_items = 5)]` | [`ValidateMinItems`] | [minItems](https://json-schema.org/understanding-json-schema/reference/array#length) |
63-
//! | Array | `#[validate(unique_items)]` | [`ValidateUniqueItems`] | [uniqueItems](https://json-schema.org/understanding-json-schema/reference/array#uniqueItems) |
64-
//! | Generic | `#[validate(enumerate(5, 10, 15))]` | [`ValidateEnumerate`] | [enum](https://json-schema.org/understanding-json-schema/reference/enum) |
49+
//! | Type | Serde Valid (validate derive) | Serde Valid (validate trait) | JSON Schema |
50+
//! | :-----: | :------------------------------------- | :--------------------------- | :-------------------------------------------------------------------------------------------- |
51+
//! | String | `#[validate(max_length = 5)]` | [`ValidateMaxLength`] | [maxLength](https://json-schema.org/understanding-json-schema/reference/string#length) |
52+
//! | String | `#[validate(min_length = 5)]` | [`ValidateMinLength`] | [minLength](https://json-schema.org/understanding-json-schema/reference/string#length) |
53+
//! | String | `#[validate(pattern = r"^\d{5}$")]` | [`ValidatePattern`] | [pattern](https://json-schema.org/understanding-json-schema/reference/string#regexp) |
54+
//! | Numeric | `#[validate(maximum = 5)]` | [`ValidateMaximum`] | [maximum](https://json-schema.org/understanding-json-schema/reference/numeric#range) |
55+
//! | Numeric | `#[validate(minimum = 5)]` | [`ValidateMinimum`] | [minimum](https://json-schema.org/understanding-json-schema/reference/numeric#range) |
56+
//! | Numeric | `#[validate(exclusive_maximum = 5)]` | [`ValidateExclusiveMaximum`] | [exclusiveMaximum](https://json-schema.org/understanding-json-schema/reference/numeric#range) |
57+
//! | Numeric | `#[validate(exclusive_minimum = 5)]` | [`ValidateExclusiveMinimum`] | [exclusiveMinimum](https://json-schema.org/understanding-json-schema/reference/numeric#range) |
58+
//! | Numeric | `#[validate(multiple_of = 5)]` | [`ValidateMultipleOf`] | [multipleOf](https://json-schema.org/understanding-json-schema/reference/numeric#multiples) |
59+
//! | Object | `#[validate(max_properties = 5)]` | [`ValidateMaxProperties`] | [maxProperties](https://json-schema.org/understanding-json-schema/reference/object#size) |
60+
//! | Object | `#[validate(min_properties = 5)]` | [`ValidateMinProperties`] | [minProperties](https://json-schema.org/understanding-json-schema/reference/object#size) |
61+
//! | Array | `#[validate(max_items = 5)]` | [`ValidateMaxItems`] | [maxItems](https://json-schema.org/understanding-json-schema/reference/array#length) |
62+
//! | Array | `#[validate(min_items = 5)]` | [`ValidateMinItems`] | [minItems](https://json-schema.org/understanding-json-schema/reference/array#length) |
63+
//! | Array | `#[validate(unique_items)]` | [`ValidateUniqueItems`] | [uniqueItems](https://json-schema.org/understanding-json-schema/reference/array#uniqueItems) |
64+
//! | Generic | `#[validate(enumerate = [5, 10, 15])]` | [`ValidateEnumerate`] | [enum](https://json-schema.org/understanding-json-schema/reference/enum) |
6565
//!
6666
//! In addition, [serde_valid::utils][module@crate::utils] provides a type of validation not described in the JSON schema specification.
6767
//!

serde_valid/src/validation/generic/enumerate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::EnumerateError;
2222
///
2323
/// #[derive(Validate)]
2424
/// struct TestStruct {
25-
/// #[validate(enumerate("1", "2", "3"))]
25+
/// #[validate(enumerate = ["1", "2", "3"])]
2626
/// val: MyType,
2727
/// }
2828
///

serde_valid/tests/complex_test.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn sample_rule(_val: i32) -> Result<(), serde_valid::validation::Error> {
88
#[validate(custom(|s| sample_rule(s.int_value)))]
99
struct TestStruct<'a> {
1010
// Generic validator
11-
#[validate(enumerate(5, 10, 15))]
11+
#[validate(enumerate = [5, 10, 15])]
1212
// Numeric validator
1313
#[validate(multiple_of = 5)]
1414
#[validate(minimum = 5)]
@@ -18,7 +18,7 @@ struct TestStruct<'a> {
1818
int_value: i32,
1919

2020
// Generic validator
21-
#[validate(enumerate(5.0, 10.0, 15.0))]
21+
#[validate(enumerate = [5.0, 10.0, 15.0])]
2222
// Numeric validator
2323
#[validate(multiple_of = 5.0)]
2424
#[validate(minimum = 5.0)]
@@ -28,31 +28,31 @@ struct TestStruct<'a> {
2828
float_value: f32,
2929

3030
// Generic validator
31-
#[validate(enumerate("12345", "67890"))]
31+
#[validate(enumerate = ["12345", "67890"])]
3232
// String validator
3333
#[validate(min_length = 5)]
3434
#[validate(max_length = 5)]
3535
#[validate(pattern = r"^\d{5}$")]
3636
string_value: String,
3737

3838
// Generic validator
39-
#[validate(enumerate("12345", "67890"))]
39+
#[validate(enumerate = ["12345", "67890"])]
4040
// String validator
4141
#[validate(min_length = 5)]
4242
#[validate(max_length = 5)]
4343
#[validate(pattern = r"^\d{5}$")]
4444
str_value: &'a str,
4545

4646
// Generic validator
47-
#[validate(enumerate(5, 10, 15))]
47+
#[validate(enumerate = [5, 10, 15])]
4848
// Numeric validator
4949
#[validate(multiple_of = 5)]
5050
#[validate(minimum = 5)]
5151
#[validate(maximum = 5)]
5252
optional_value: Option<i32>,
5353

5454
// Generic validator
55-
#[validate(enumerate(5, 10, 15))]
55+
#[validate(enumerate = [5, 10, 15])]
5656
// Array validator
5757
#[validate(unique_items)]
5858
#[validate(min_items = 3)]
@@ -78,7 +78,7 @@ struct TestStruct<'a> {
7878
#[derive(Debug, Validate)]
7979
struct TestInnerStruct<'a> {
8080
// Generic validator
81-
#[validate(enumerate(5, 10, 15))]
81+
#[validate(enumerate = [5, 10, 15])]
8282
// Numeric validator
8383
#[validate(multiple_of = 5)]
8484
#[validate(minimum = 5)]
@@ -88,7 +88,7 @@ struct TestInnerStruct<'a> {
8888
inner_int_value: i32,
8989

9090
// Generic validator
91-
#[validate(enumerate(5.0, 10.0, 15.0))]
91+
#[validate(enumerate = [5.0, 10.0, 15.0])]
9292
// Numeric validator
9393
#[validate(multiple_of = 5.0)]
9494
#[validate(minimum = 5.0)]
@@ -98,31 +98,31 @@ struct TestInnerStruct<'a> {
9898
inner_float_value: f32,
9999

100100
// Generic validator
101-
#[validate(enumerate("12345", "67890"))]
101+
#[validate(enumerate = ["12345", "67890"])]
102102
// String validator
103103
#[validate(min_length = 5)]
104104
#[validate(max_length = 5)]
105105
#[validate(pattern = r"^\d{5}$")]
106106
inner_string_value: String,
107107

108108
// Generic validator
109-
#[validate(enumerate("12345", "67890"))]
109+
#[validate(enumerate = ["12345", "67890"])]
110110
// String validator
111111
#[validate(min_length = 5)]
112112
#[validate(max_length = 5)]
113113
#[validate(pattern = r"^\d{5}$")]
114114
inner_str_value: &'a str,
115115

116116
// Generic validator
117-
#[validate(enumerate(5, 10, 15))]
117+
#[validate(enumerate = [5, 10, 15])]
118118
// Numeric validator
119119
#[validate(multiple_of = 5)]
120120
#[validate(minimum = 5)]
121121
#[validate(maximum = 5)]
122122
inner_optional_value: Option<i32>,
123123

124124
// Generic validator
125-
#[validate(enumerate(5, 10, 15))]
125+
#[validate(enumerate = [5, 10, 15])]
126126
// Array validator
127127
#[validate(unique_items)]
128128
#[validate(min_items = 3)]

0 commit comments

Comments
 (0)