Skip to content

Commit

Permalink
Check duplicate items names
Browse files Browse the repository at this point in the history
Signed-off-by: Sergio Castaño Arteaga <[email protected]>
  • Loading branch information
tegioz committed Aug 28, 2023
1 parent 64d4af8 commit ebb98e6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit ebb98e6

Please sign in to comment.