aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorVincent Prouillet2019-05-01 21:36:09 +0200
committerVincent Prouillet2019-05-01 21:37:37 +0200
commit36f6535f6d0c1b680eb396159c27c6c44e63bc79 (patch)
treeb95b5f82eb97b9361b371433edce48d2f5aa6ef8 /README.md
parent798988018920144535f2bd5aa93a8d3f4423b42c (diff)
downloadvalidator-36f6535f6d0c1b680eb396159c27c6c44e63bc79.tar.bz2
attr_literals is stable \o/
Diffstat (limited to 'README.md')
-rw-r--r--README.md38
1 files changed, 18 insertions, 20 deletions
diff --git a/README.md b/README.md
index 09d2982..f3e98d4 100644
--- a/README.md
+++ b/README.md
@@ -4,12 +4,6 @@
Macros 1.1 custom derive to simplify struct validation inspired by [marshmallow](http://marshmallow.readthedocs.io/en/latest/) and
[Django validators](https://docs.djangoproject.com/en/1.10/ref/validators/).
-It relies on the `proc_macro` feature which is stable since Rust 1.15.
-
-By default all args to a `validate` must be strings if you are using stable.
-However, if you are using nightly, you can also activate the `attr_literals` feature to be able to use int, float and boolean as well.
-
-
A short example:
```rust
@@ -31,10 +25,10 @@ struct SignupData {
phone: String,
#[validate(url)]
site: String,
- #[validate(length(min = "1"), custom = "validate_unique_username")]
+ #[validate(length(min = 1), custom = "validate_unique_username")]
#[serde(rename = "firstName")]
first_name: String,
- #[validate(range(min = "18", max = "20"))]
+ #[validate(range(min = 18, max = 20))]
age: u32,
}
@@ -117,7 +111,7 @@ struct ContactDetails {
#[derive(Debug, Validate, Deserialize)]
struct Preference {
- #[validate(length(min = "4"))]
+ #[validate(length(min = 4))]
name: String,
value: bool,
}
@@ -172,10 +166,10 @@ At least one argument is required with a maximum of 2 (having `min` and `max` at
Examples:
```rust
-#[validate(length(min = "1", max = "10"))]
-#[validate(length(min = "1"))]
-#[validate(length(max = "10"))]
-#[validate(length(equal = "10"))]
+#[validate(length(min = 1, max = 10))]
+#[validate(length(min = 1))]
+#[validate(length(max = 10))]
+#[validate(length(equal = 10))]
```
### range
@@ -184,11 +178,11 @@ Tests whether a number is in the given range. `range` takes between 1 and 2 numb
Examples:
```rust
-#[validate(range(min = "1", max = "10"))]
-#[validate(range(min = "1"))]
-#[validate(range(min = "1", max = "10.8"))]
-#[validate(range(min = "1.1", max = "10.8"))]
-#[validate(range(max = "10.8"))]
+#[validate(range(min = 1, max = 10))]
+#[validate(range(min = 1))]
+#[validate(range(min = 1, max = 10.8))]
+#[validate(range(min = 1.1, max = 10.8))]
+#[validate(range(max = 10.8))]
```
### must_match
@@ -263,7 +257,7 @@ Often, some error validation can only be applied when looking at the full struct
```rust
#[derive(Debug, Validate, Deserialize)]
-#[validate(schema(function = "validate_category", skip_on_field_errors = "false"))]
+#[validate(schema(function = "validate_category", skip_on_field_errors = false))]
struct CategoryData {
category: String,
name: String,
@@ -300,7 +294,7 @@ For example, the following attributes all work:
### validator
-#### 0.9.0 (2019/05/01)
+#### 0.9.0 (2019/05/xx)
- `ValidationErrors::errors` and `ValidationErrors::field_errors` now use `&self` instead of `self`
@@ -330,6 +324,10 @@ For example, the following attributes all work:
### validator_derive
+#### 0.9.0 (2019/05/xx)
+
+- Use literals in macros now that it's stable -> bumping minimum Rust version to 1.34
+
#### 0.8.0 (2018/09/19)
- Allow nested validation