validatornator/validators/
usize.rs1use crate::prelude::{ValidationError, ValidationHelper, ValidationResult};
2
3pub trait USizeValidator {
4 fn be_larger_than(self, limit: usize) -> ValidationResult<usize>;
5 fn be_smaller_than(self, limit: usize) -> ValidationResult<usize>;
6}
7
8impl USizeValidator for ValidationResult<usize> {
9 fn be_larger_than(self, limit: usize) -> ValidationResult<usize> {
10 self.validate(
11 Box::new(
12 move |v| v > &limit
13 ),
14 &format! ("Value is not larger than {}.", limit)
15 )
16 }
17
18 fn be_smaller_than(self, limit: usize) -> ValidationResult<usize> {
19 self.validate(
20 Box::new(
21 move |v| v < &limit
22 ),
23 &format! ("Value is not smaller than {}.", limit)
24 )
25 }
26}