Search in sources :

Example 1 with DefaultSeverityRegistry

use of io.apicurio.datamodels.core.validation.DefaultSeverityRegistry in project apicurio-data-models by Apicurio.

the class Library method validate.

/**
 * @deprecated
 * This method has been deprecated. It will continue to be supported but will be removed in a future release.
 * <p> Use {@link Library#validateDocument(Node, IValidationSeverityRegistry, List)} instead.
 *
 * 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.
 * @param node
 * @param severityRegistry
 */
public static List<ValidationProblem> validate(Node node, IValidationSeverityRegistry severityRegistry) {
    if (severityRegistry == null) {
        severityRegistry = new DefaultSeverityRegistry();
    }
    // Clear/reset any problems that may have been found before.
    ValidationProblemsResetVisitor resetter = VisitorFactory.createValidationProblemsResetVisitor(node.ownerDocument());
    visitTree(node, resetter, TraverserDirection.down);
    // Validate the data model.
    ValidationVisitor validator = VisitorFactory.createValidationVisitor(node.ownerDocument());
    validator.setSeverityRegistry(severityRegistry);
    visitTree(node, validator, TraverserDirection.down);
    return validator.getValidationProblems();
}
Also used : ValidationVisitor(io.apicurio.datamodels.core.validation.ValidationVisitor) DefaultSeverityRegistry(io.apicurio.datamodels.core.validation.DefaultSeverityRegistry) ValidationProblemsResetVisitor(io.apicurio.datamodels.core.validation.ValidationProblemsResetVisitor)

Aggregations

DefaultSeverityRegistry (io.apicurio.datamodels.core.validation.DefaultSeverityRegistry)1 ValidationProblemsResetVisitor (io.apicurio.datamodels.core.validation.ValidationProblemsResetVisitor)1 ValidationVisitor (io.apicurio.datamodels.core.validation.ValidationVisitor)1