From 61f61ceb9b2f341ebb153a1f66d3c8ef27faba93 Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Fri, 29 Sep 2023 11:09:20 +0200 Subject: [PATCH] Ignore clippy warning when length must be >= 1 Fixes: https://github.com/lumeohq/xsd-parser-rs/issues/120 --- xsd-parser/src/generator/validator.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xsd-parser/src/generator/validator.rs b/xsd-parser/src/generator/validator.rs index 4bfd2258..f8fa63c8 100644 --- a/xsd-parser/src/generator/validator.rs +++ b/xsd-parser/src/generator/validator.rs @@ -129,6 +129,7 @@ fn gen_min_length_validation(value: &str, name: &str) -> String { format!( r#" + #[allow(clippy::len_zero)] if self.{name}.len() < {value} {{ return Err(format!("MinLength validation error. \nExpected: {name} length >= {value} \nActual: {name} length == {{}}", self.{name}.len())); }}"#, @@ -208,6 +209,7 @@ mod test { #[test] fn test_gen_min_length_validation() { let expected = r#" + #[allow(clippy::len_zero)] if self.name.len() < 50 { return Err(format!("MinLength validation error. \nExpected: name length >= 50 \nActual: name length == {}", self.name.len())); }"#;