Update input validator errors to be standardized
This commit is contained in:
parent
009ff2d2d6
commit
e96ee8a8d6
@ -15,7 +15,7 @@ impl InputValueValidator for IntRange {
|
|||||||
if let Value::Int(n) = value {
|
if let Value::Int(n) = value {
|
||||||
if *n < self.min || *n > self.max {
|
if *n < self.min || *n > self.max {
|
||||||
Some(format!(
|
Some(format!(
|
||||||
"the value is {}, but the range must be between {} and {}",
|
"the value is {}, must be between {} and {}",
|
||||||
*n, self.min, self.max
|
*n, self.min, self.max
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
@ -80,7 +80,7 @@ impl InputValueValidator for IntNonZero {
|
|||||||
fn is_valid(&self, value: &Value) -> Option<String> {
|
fn is_valid(&self, value: &Value) -> Option<String> {
|
||||||
if let Value::Int(n) = value {
|
if let Value::Int(n) = value {
|
||||||
if *n == 0 {
|
if *n == 0 {
|
||||||
Some(format!("the value is {}, but must be nonzero", *n,))
|
Some(format!("the value is {}, must be nonzero", *n,))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ impl InputValueValidator for IntEqual {
|
|||||||
fn is_valid(&self, value: &Value) -> Option<String> {
|
fn is_valid(&self, value: &Value) -> Option<String> {
|
||||||
if let Value::Int(n) = value {
|
if let Value::Int(n) = value {
|
||||||
if *n != self.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 {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ impl InputValueValidator for ListMinLength {
|
|||||||
if let Value::List(values) = value {
|
if let Value::List(values) = value {
|
||||||
if values.len() < self.length as usize {
|
if values.len() < self.length as usize {
|
||||||
Some(format!(
|
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(),
|
values.len(),
|
||||||
self.length
|
self.length
|
||||||
))
|
))
|
||||||
@ -36,7 +36,7 @@ impl InputValueValidator for ListMaxLength {
|
|||||||
if let Value::List(values) = value {
|
if let Value::List(values) = value {
|
||||||
if values.len() > self.length as usize {
|
if values.len() > self.length as usize {
|
||||||
Some(format!(
|
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(),
|
values.len(),
|
||||||
self.length
|
self.length
|
||||||
))
|
))
|
||||||
|
@ -14,7 +14,7 @@ impl InputValueValidator for StringMinLength {
|
|||||||
if let Value::String(s) = value {
|
if let Value::String(s) = value {
|
||||||
if s.len() < self.length as usize {
|
if s.len() < self.length as usize {
|
||||||
Some(format!(
|
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(),
|
s.len(),
|
||||||
self.length
|
self.length
|
||||||
))
|
))
|
||||||
@ -38,7 +38,7 @@ impl InputValueValidator for StringMaxLength {
|
|||||||
if let Value::String(s) = value {
|
if let Value::String(s) = value {
|
||||||
if s.len() > self.length as usize {
|
if s.len() > self.length as usize {
|
||||||
Some(format!(
|
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(),
|
s.len(),
|
||||||
self.length
|
self.length
|
||||||
))
|
))
|
||||||
|
Loading…
Reference in New Issue
Block a user