Skip to content

Commit

Permalink
fix: RO-Crate validation should work for nested properties without id
Browse files Browse the repository at this point in the history
fixes issue #27
  • Loading branch information
Daniel Bauer committed Nov 12, 2024
1 parent bcbe829 commit e38e724
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def check_context(self, context: ValidationContext) -> bool:
@check(name="File Descriptor JSON-LD must be flattened")
def check_flattened(self, context: ValidationContext) -> bool:
""" Check if the file descriptor is flattened """

def is_entity_flat_recursive(entity: Any, is_first: bool = True) -> bool:
""" Recursively check if the given data corresponds to a flattened JSON-LD object
and returns False if it does not and is not a root element
Expand All @@ -109,7 +108,7 @@ def is_entity_flat_recursive(entity: Any, is_first: bool = True) -> bool:
return False
# if this is not the root element, it must not contain more properties than @id
else:
if "@id" in entity and len(entity) > 1:
if "@id" not in entity or len(entity) > 1:
return False
if isinstance(entity, list):
for element in entity:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@
"@id": "https://w3id.org/ro/crate/1.1"
},
"about": {
"@type": "Dataset",
"@id": "./",
"hasPart": [
{
"@type": "File",
"@id": "test.csv",
"encodingFormat": "text/csv",
"name": "This is a test file",
"description": "This is a test dataset"
}
],
"name": "This is a test dataset",
"description": "This is a test dataset",
"license": {
"@id": "https://creativecommons.org/licenses/by/4.0/"
},
"datePublished": "2024-11-05"
"@id": "./"
}
},
{
"@id": "./",
"@type": "Dataset",
"name": "This is a test dataset",
"description": "This is a test dataset",
"license": {
"@id": "https://creativecommons.org/licenses/by/4.0/"
},
"datePublished": "2024-11-05",
"hasPart": [
{
"@type": "File",
"name": "File in a nested entity"
}
]
}
]
}

0 comments on commit e38e724

Please sign in to comment.