use of io.apicurio.datamodels.core.validation.IValidationSeverityRegistry in project apicurio-data-models by Apicurio.
the class Library method validateDocument.
/**
* Called to validate a data model node. All validation rules will be evaluated and reported. The list
* of validation problems found during validation is returned. In addition, validation problems will be
* reported on the individual nodes themselves. Validation problem severity is determined by checking
* with the included severity registry. If the severity registry is null, a default registry is used.
* Custom validators can be passed to provide additional validation rules beyond what this Library offers out of the box.
*
* @param node The document to be validated
* @param severityRegistry Supply a custom severity registry. If nothing is passed, the default severity registry will be used
* @param extensions Supply an optional list of validation extensions, enabling the use of 3rd-party validators or custom validation rules
* @return full list of the validation problems found in the document
*/
public static CompletableFuture<List<ValidationProblem>> validateDocument(Node node, IValidationSeverityRegistry severityRegistry, List<IDocumentValidatorExtension> extensions) {
List<ValidationProblem> totalValidationProblems = Library.validate(node, severityRegistry);
if (extensions != null && !extensions.isEmpty()) {
for (IDocumentValidatorExtension extension : extensions) {
CompletableFuture<List<ValidationProblem>> extensionValidationProblems = extension.validateDocument(node);
extensionValidationProblems.thenAccept(problems -> problems.forEach(p -> {
totalValidationProblems.add(p);
node.ownerDocument().addValidationProblem(p.errorCode, p.nodePath, p.property, p.message, p.severity);
}));
}
}
return CompletableFuture.completedFuture(totalValidationProblems);
}
Aggregations