def validate(self, document, location=None): if location is None: location = YAMLLocation() document = copy.deepcopy(document) return_snippet = [] if type(location.get(document)) != CommentedSeq: raise_exception( "when expecting a unique sequence", "found non-sequence", document, location=location, ) else: existing_items = set() for i, item in enumerate(location.get(document)): if item in existing_items: raise_exception( "while parsing a sequence", "duplicate found", document, location=location ) else: existing_items.add(item) return_snippet.append(self._validator(document, location=location.index(i))) return return_snippet
def validate(self, document, location=None): if location is None: location = YAMLLocation() document = copy.deepcopy(document) return_snippet = [] if type(location.get(document)) != CommentedSeq: raise_exception( "when expecting a sequence", "found non-sequence", document, location=location, ) else: for i, item in enumerate(location.get(document)): return_snippet.append(self._validator(document, location=location.index(i))) return return_snippet