From e96ee8a8d62196e04667540dc57bbf5a4f3e101c Mon Sep 17 00:00:00 2001 From: Kevin Schoonover Date: Sat, 30 May 2020 15:09:16 -0500 Subject: [PATCH] Update input validator errors to be standardized --- src/validators/int_validators.rs | 6 +++--- src/validators/list_validators.rs | 4 ++-- src/validators/string_validators.rs | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/validators/int_validators.rs b/src/validators/int_validators.rs index 003e1727..ba0b2c06 100644 --- a/src/validators/int_validators.rs +++ b/src/validators/int_validators.rs @@ -15,7 +15,7 @@ impl InputValueValidator for IntRange { if let Value::Int(n) = value { if *n < self.min || *n > self.max { Some(format!( - "the value is {}, but the range must be between {} and {}", + "the value is {}, must be between {} and {}", *n, self.min, self.max )) } else { @@ -80,7 +80,7 @@ impl InputValueValidator for IntNonZero { fn is_valid(&self, value: &Value) -> Option { if let Value::Int(n) = value { if *n == 0 { - Some(format!("the value is {}, but must be nonzero", *n,)) + Some(format!("the value is {}, must be nonzero", *n,)) } else { None } @@ -100,7 +100,7 @@ impl InputValueValidator for IntEqual { fn is_valid(&self, value: &Value) -> Option { if let Value::Int(n) = value { if *n != self.value { - Some(format!("the value is {}, must be equal {}", *n, self.value)) + Some(format!("the value is {}, must be equal to {}", *n, self.value)) } else { None } diff --git a/src/validators/list_validators.rs b/src/validators/list_validators.rs index 5404ba0a..ca37efdf 100644 --- a/src/validators/list_validators.rs +++ b/src/validators/list_validators.rs @@ -12,7 +12,7 @@ impl InputValueValidator for ListMinLength { if let Value::List(values) = value { if values.len() < self.length as usize { Some(format!( - "the value length is {}, but the length must be greater than or equal to {}", + "the value length is {}, must be greater than or equal to {}", values.len(), self.length )) @@ -36,7 +36,7 @@ impl InputValueValidator for ListMaxLength { if let Value::List(values) = value { if values.len() > self.length as usize { Some(format!( - "the value length is {}, but the length must be less than or equal to {}", + "the value length is {}, must be less than or equal to {}", values.len(), self.length )) diff --git a/src/validators/string_validators.rs b/src/validators/string_validators.rs index 224745fc..77d31f94 100644 --- a/src/validators/string_validators.rs +++ b/src/validators/string_validators.rs @@ -14,7 +14,7 @@ impl InputValueValidator for StringMinLength { if let Value::String(s) = value { if s.len() < self.length as usize { Some(format!( - "the value length is {}, but the length must be greater than or equal to {}", + "the value length is {}, must be greater than or equal to {}", s.len(), self.length )) @@ -38,7 +38,7 @@ impl InputValueValidator for StringMaxLength { if let Value::String(s) = value { if s.len() > self.length as usize { Some(format!( - "the value length is {}, but the length must be less than or equal to {}", + "the value length is {}, must be less than or equal to {}", s.len(), self.length ))