You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
final JsonNode jsonNodeSchema = ObjectMapperUtil.readTree(SCHEMA);
final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersionDetector.detect(jsonNodeSchema));
final JsonSchema validator = factory.getSchema(jsonNodeSchema, SchemaValidatorsConfig.builder()
.nullableKeywordEnabled(false)
.build());
final JsonNode jsonNodeFromString = ObjectMapperUtil.readTree(DATA);
final Set<ValidationMessage> errors = validator.validate(jsonNodeFromString);
if (!errors.isEmpty()) {
throw new RuntimeException(errors.toString());
}
Expectation:
An error message to always be shown, irrespective of 'nullable': "/test/nested: null found, string expected"
This is because in the json schema specification the 'nullable' keyword does not exist and setting it to either true/false should have no effect on the validation.
Actual result:
setting the 'nullable' flag in the schema to true: no error message
setting the 'nullable' flag in the schema to false: error message shown "/test/nested: null found, string expected"
DanNemes
changed the title
Validator not respecting json schema validation Specification standard
Validator does not comply with JSON Schema validation standards
Nov 25, 2024
Given this schema:
This input:
And this java snippet
Expectation:
An error message to always be shown, irrespective of 'nullable': "/test/nested: null found, string expected"
This is because in the json schema specification the 'nullable' keyword does not exist and setting it to either true/false should have no effect on the validation.
Actual result:
setting the 'nullable' flag in the schema to true: no error message
setting the 'nullable' flag in the schema to false: error message shown "/test/nested: null found, string expected"
Using the same json schema and input on the following site would yield the correct error:
https://www.jsonschemavalidator.net/
The text was updated successfully, but these errors were encountered: