diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PatternPropertiesKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PatternPropertiesKeywordType.java index d68f27f7..8d35c465 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PatternPropertiesKeywordType.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PatternPropertiesKeywordType.java @@ -91,11 +91,9 @@ private boolean propertyMatches(final Map.Entry 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 diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PatternPropertiesKeywordTypeTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PatternPropertiesKeywordTypeTest.java index aa6c7f8e..7c498208 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PatternPropertiesKeywordTypeTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PatternPropertiesKeywordTypeTest.java @@ -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(