Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue in patternproperties not evaluate all schemas #31

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,9 @@ private boolean propertyMatches(final Map.Entry<String, JsonValue> property) {
.entrySet()
.stream()
.filter(e -> e.getKey().matcher(property.getKey()).find())
.findFirst()
.map(Map.Entry::getValue)
.map(JsonSchemas::load)
.map(schema -> schema.validator().validate(property.getValue()).isEmpty())
.orElse(true);
.allMatch(schema -> schema.validator().validate(property.getValue()).isEmpty());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,25 @@ void should_be_invalid_if_properties_not_applies_to_his_schema() {
);
}

/*
Attention can be falky.
JsonObject is a map, so the properties occurred in random order.
This means for this test it could be green without using all assertions.
*/
@Test
void should_be_invalid_if_one_schema_doesn_apply() {
assertThat(
new PatternPropertiesKeywordType()
.createKeyword(
new DefaultJsonSchemaFactory().create(JsonValue.TRUE),
Json.createObjectBuilder().add("t.st", JsonValue.TRUE).add("t.*", JsonValue.FALSE).build()
)
.asApplicator()
.applyTo(Json.createObjectBuilder().add("test", 1).build()),
is(false)
);
}

@Test
void should_be_valid_if_properties_not_covered() {
assertThat(
Expand Down