Repository: networknt/json-schema-validator (java)

Issue:
Disabling format assertions for draft-07 doesn't seem to work
I'm trying to use a similar example to the one given in the README to force assertions to be disabled but when I execute this, I still get validation errors referring to the format. This also happens if I set the same option to false when building the config for the schema.

```
Set<ValidationMessage> = schema.validate(input, OutputFormat.DEFAULT, executionContext -> {
    // By default since Draft 07 the format keyword generates assertions
    executionContext.getExecutionConfig().setFormatAssertionsEnabled(false);
});

```

Pull request description:
Fix explicit disabling of format assertions
Closes #1144

This also fixes the `SchemaValidatorsConfig` builder to initialise `formatAssertionsEnabled` to `null` instead of `false`.

Patch:
diff --git a/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java b/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java
index c9d9b7a..beb25d7 100644
--- a/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java
+++ b/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java
@@ -817,7 +817,7 @@ public class SchemaValidatorsConfig {
         private String errorMessageKeyword = null;
         private ExecutionContextCustomizer executionContextCustomizer = null;
         private boolean failFast = false;
-        private Boolean formatAssertionsEnabled = false;
+        private Boolean formatAssertionsEnabled = null;
         private boolean nullableKeywordEnabled = false;
         private List<JsonSchemaWalkListener> itemWalkListeners = new ArrayList<>();
         private boolean javaSemantics = false;
diff --git a/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java b/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java
index 6412506..f2665bb 100644
--- a/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java
+++ b/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java
@@ -49,6 +49,8 @@ public abstract class BaseFormatJsonValidator extends BaseJsonValidator {
     protected boolean isAssertionsEnabled(ExecutionContext executionContext) {
         if (Boolean.TRUE.equals(executionContext.getExecutionConfig().getFormatAssertionsEnabled())) {
             return true;
+        } else if (Boolean.FALSE.equals(executionContext.getExecutionConfig().getFormatAssertionsEnabled())) {
+            return false;
         }
         return this.assertionsEnabled;
     }


Test patch:
diff --git a/src/test/java/com/networknt/schema/FormatValidatorTest.java b/src/test/java/com/networknt/schema/FormatValidatorTest.java
index acd15af..8e41110 100644
--- a/src/test/java/com/networknt/schema/FormatValidatorTest.java
+++ b/src/test/java/com/networknt/schema/FormatValidatorTest.java
@@ -233,4 +233,16 @@ class FormatValidatorTest {
         assertTrue(messages.isEmpty());
         
     }
+
+    @Test
+    void draft7DisableFormat() {
+        String schemaData = "{\r\n"
+                + "  \"format\":\"uri\"\r\n"
+                + "}";
+        JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V7).getSchema(schemaData);
+        Set<ValidationMessage> messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> {
+            executionContext.getExecutionConfig().setFormatAssertionsEnabled(false);
+        });
+        assertEquals(0, messages.size());
+    }
 }