aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Prouillet2018-09-19 09:55:31 +0200
committerVincent Prouillet2018-09-19 09:55:31 +0200
commit33833d20f7c2c9f78b4a7d940b76ce31ad223766 (patch)
treeb3a61201a9a59350ebb5f321223a9d34453d8586
parenta1d0f78318762f51d80cd9f847375bd6fc445e79 (diff)
downloadvalidator-33833d20f7c2c9f78b4a7d940b76ce31ad223766.tar.bz2
Prepare for 0.8.0 release
-rw-r--r--README.md10
-rw-r--r--validator/Cargo.toml6
-rw-r--r--validator/src/traits.rs4
-rw-r--r--validator/src/types.rs12
-rw-r--r--validator_derive/Cargo.toml4
5 files changed, 18 insertions, 18 deletions
diff --git a/README.md b/README.md
index 16ddd0e..0ac7436 100644
--- a/README.md
+++ b/README.md
@@ -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"