From ebb98e6f255b305506861e69a2b70669dd996b26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Casta=C3=B1o=20Arteaga?= Date: Mon, 28 Aug 2023 14:24:54 +0200 Subject: [PATCH] Check duplicate items names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sergio CastaƱo Arteaga --- src/data.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/data.rs b/src/data.rs index e9d703f2..6ab375d9 100644 --- a/src/data.rs +++ b/src/data.rs @@ -543,6 +543,8 @@ mod legacy { impl LandscapeData { /// Validate landscape data. pub(super) fn validate(&self) -> Result<()> { + let mut items_seen = Vec::new(); + for (category_index, category) in self.landscape.iter().enumerate() { // Check category name if category.name.is_empty() { @@ -574,6 +576,10 @@ mod legacy { if item.name.is_empty() { return Err(format_err!("name is required")).context(ctx); } + if items_seen.contains(&item.name) { + return Err(format_err!("duplicate item name")).context(ctx); + } + items_seen.push(item.name.clone()); // Check homepage if item.homepage_url.is_empty() {