Skip to content

NullPointerException in regex pattern validation if no SchemaValidatorsConfig is passed #280

@foldvari

Description

@foldvari

It is possible to load a schema without a SchemaValidatorsConfig but in this case the validation of the schema itself will fail at regex pattern validation.

Location of the exception:

compileRegexPattern(pattern, validationContext.getConfig().isEcma262Validator());

public PatternValidator(String schemaPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) {

        super(schemaPath, schemaNode, parentSchema, ValidatorTypeCode.PATTERN, validationContext);
        pattern = "";
        if (schemaNode != null && schemaNode.isTextual()) {
            pattern = schemaNode.textValue();
            try {
                compileRegexPattern(pattern, validationContext.getConfig().isEcma262Validator());
            } catch (PatternSyntaxException pse) {
                logger.error("Failed to compile pattern : Invalid syntax [" + pattern + "]", pse);
                throw pse;
            } catch (SyntaxException se) {
                logger.error("Failed to compile pattern : Invalid syntax [" + pattern + "]", se);
                throw se;
            }
        }


Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions