diff options
| author | Vincent Prouillet | 2018-09-19 09:55:31 +0200 | 
|---|---|---|
| committer | Vincent Prouillet | 2018-09-19 09:55:31 +0200 | 
| commit | 33833d20f7c2c9f78b4a7d940b76ce31ad223766 (patch) | |
| tree | b3a61201a9a59350ebb5f321223a9d34453d8586 | |
| parent | a1d0f78318762f51d80cd9f847375bd6fc445e79 (diff) | |
| download | validator-33833d20f7c2c9f78b4a7d940b76ce31ad223766.tar.bz2 | |
Prepare for 0.8.0 release
| -rw-r--r-- | README.md | 10 | ||||
| -rw-r--r-- | validator/Cargo.toml | 6 | ||||
| -rw-r--r-- | validator/src/traits.rs | 4 | ||||
| -rw-r--r-- | validator/src/types.rs | 12 | ||||
| -rw-r--r-- | validator_derive/Cargo.toml | 4 | 
5 files changed, 18 insertions, 18 deletions
| @@ -133,7 +133,7 @@ these child types also derive `Validate`, the fields where they appear can be ta  struct's validation method.  Any errors found in a single nested struct (the `contact_details` field in this example) would be returned as a -`Struct(Box<ValidationErrors>)` type in the parent's `ValidationErrors` result.  +`Struct(Box<ValidationErrors>)` type in the parent's `ValidationErrors` result.  Any errors found in a vector of nested structs (the `preferences` field in this example) would be returned as a  `List(BTreeMap<usize, Box<ValidationErrors>>)` type in the parent's `ValidationErrors` result, where the map is keyed on @@ -298,6 +298,10 @@ For example, the following attributes all work:  ### validator +#### 0.8.0 (2018/09/19) + +- Change error type to allow use with nested validation +  #### 0.7.1 (2018/07/27)  - Make validators work on `Cow` @@ -320,6 +324,10 @@ For example, the following attributes all work:  ### validator_derive +#### 0.8.0 (2018/09/19) + +- Allow nested validation +  #### 0.7.2 (2018/07/27)  - Make validators work on `Cow` diff --git a/validator/Cargo.toml b/validator/Cargo.toml index 5cc6589..f107fbb 100644 --- a/validator/Cargo.toml +++ b/validator/Cargo.toml @@ -1,9 +1,9 @@  [package]  name = "validator" -version = "0.7.1" -authors = ["Vincent Prouillet <vincent@wearewizards.io>"] +version = "0.8.0" +authors = ["Vincent Prouillet <prouillet.vincent@gmail.com"]  license = "MIT" -description = "Common validation functions (email, url, length, ...) and trait" +description = "Common validation functions (email, url, length, ...) and trait - to be used with `validator_derive`"  homepage = "https://github.com/Keats/validator"  repository = "https://github.com/Keats/validator"  keywords = ["validation", "api", "validator"] diff --git a/validator/src/traits.rs b/validator/src/traits.rs index f59113c..8d0b129 100644 --- a/validator/src/traits.rs +++ b/validator/src/traits.rs @@ -76,13 +76,13 @@ impl<'a> Contains for Cow<'a, str> {      }  } -impl<S> Contains for HashMap<String, S> { +impl<S, H: ::std::hash::BuildHasher> Contains for HashMap<String, S, H> {      fn has_element(&self, needle: &str) -> bool {          self.contains_key(needle)      }  } -impl<'a, S> Contains for &'a HashMap<String, S> { +impl<'a, S, H: ::std::hash::BuildHasher> Contains for &'a HashMap<String, S, H> {      fn has_element(&self, needle: &str) -> bool {          self.contains_key(needle)      } diff --git a/validator/src/types.rs b/validator/src/types.rs index d26079b..77033d9 100644 --- a/validator/src/types.rs +++ b/validator/src/types.rs @@ -45,7 +45,7 @@ pub enum ValidationErrorsKind {      Field(Vec<ValidationError>),  } -#[derive(Debug, Serialize, Clone, PartialEq)] +#[derive(Default, Debug, Serialize, Clone, PartialEq)]  pub struct ValidationErrors(HashMap<&'static str, ValidationErrorsKind>);  impl ValidationErrors { @@ -126,17 +126,9 @@ impl ValidationErrors {              }).collect()      } -    #[deprecated( -        since = "0.7.3", -        note = "Use `field_errors` instead, or `errors` to also access any errors from nested structs" -    )] -    pub fn inner(self) -> HashMap<&'static str, Vec<ValidationError>> { -        self.field_errors() -    } -      pub fn add(&mut self, field: &'static str, error: ValidationError) {          if let ValidationErrorsKind::Field(ref mut vec) = -            self.0.entry(field).or_insert(ValidationErrorsKind::Field(vec![])) +            self.0.entry(field).or_insert_with(|| ValidationErrorsKind::Field(vec![]))          {              vec.push(error);          } else { diff --git a/validator_derive/Cargo.toml b/validator_derive/Cargo.toml index d7bf3bb..c7dc0db 100644 --- a/validator_derive/Cargo.toml +++ b/validator_derive/Cargo.toml @@ -1,7 +1,7 @@  [package]  name = "validator_derive" -version = "0.7.2" -authors = ["Vincent Prouillet <vincent@wearewizards.io>"] +version = "0.8.0" +authors = ["Vincent Prouillet <prouillet.vincent@gmail.com"]  license = "MIT"  description = "Macros 1.1 implementation of #[derive(Validate)]"  homepage = "https://github.com/Keats/validator" | 
