protected void visit()

in src/main/java/org/apache/sling/validation/impl/ValidationResourceVisitor.java [50:71]


    protected void visit(Resource resource) {
        if (isValidSubResource(resource)) {
            @SuppressWarnings("null")
            ValidationModel model = validationService.getValidationModel(resource, considerResourceSuperTypeModels);
            if (model == null) {
                if (enforceValidation) {
                    throw new IllegalArgumentException("No model for resource type " + resource.getResourceType() + " found.");
                }
                return;
            }
            // calculate the property name correctly from the root
            // the relative path must not end with a slash and not start with a slash
            @NotNull final String relativePath;
            if (resource.getPath().startsWith(rootResourcePath)) {
                relativePath = resource.getPath().substring(rootResourcePath.length());
            } else {
                relativePath = "";
            }
            ValidationResult localResult = validationService.validate(resource, model, relativePath);
            result.addValidationResult(localResult);
        }
    }