Skip to content

Commit 8550c0f

Browse files
committed
[validation] Add document unique id validation
1 parent 7e342e2 commit 8550c0f

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

odml/validation.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ def section_repository_should_be_present(sec):
129129
Validation.register_handler('section', section_repository_should_be_present)
130130

131131

132+
def document_unique_ids(doc):
133+
id_map = {doc.id: "Document '%s'" % doc.get_path()}
134+
for e in section_unique_ids(doc, id_map):
135+
yield e
136+
137+
132138
def section_unique_ids(parent, id_map=None):
133139
if not id_map:
134140
id_map = {}
@@ -151,6 +157,9 @@ def section_unique_ids(parent, id_map=None):
151157
yield e
152158

153159

160+
Validation.register_handler('odML', document_unique_ids)
161+
162+
154163
def object_unique_names(obj, children, attr=lambda x: x.name,
155164
msg="Object names must be unique"):
156165
"""

0 commit comments

Comments
 (0)