Skip to content

Commit 244ab0c

Browse files
committed
Rename JsonSchemaValidator to Validator
1 parent 34b8c17 commit 244ab0c

File tree

5 files changed

+22
-20
lines changed

5 files changed

+22
-20
lines changed

src/main/java/com/networknt/schema/JsonSchema.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
* JsonSchema instances are thread-safe provided its configuration is not
4747
* modified.
4848
*/
49-
public class JsonSchema implements JsonSchemaValidator {
49+
public class JsonSchema implements Validator {
5050
private static final long V201909_VALUE = VersionFlag.V201909.getVersionFlagValue();
5151
private final String id;
5252

src/main/java/com/networknt/schema/JsonValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/**
2020
* KeywordValidator interface implemented by all keyword validators.
2121
*/
22-
public interface JsonValidator extends JsonSchemaValidator {
22+
public interface JsonValidator extends Validator {
2323
/**
2424
* In case the {@link com.networknt.schema.JsonValidator} has a related {@link com.networknt.schema.JsonSchema} or several
2525
* ones, calling preloadJsonSchema will actually load the schema document(s) eagerly.

src/main/java/com/networknt/schema/UnionTypeValidator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
public class UnionTypeValidator extends BaseJsonValidator implements JsonValidator {
3030
private static final Logger logger = LoggerFactory.getLogger(UnionTypeValidator.class);
3131

32-
private final List<JsonSchemaValidator> schemas;
32+
private final List<Validator> schemas;
3333
private final String error;
3434

3535
public UnionTypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) {
@@ -79,7 +79,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode
7979
List<Error> test = new ArrayList<>();
8080
executionContext.setFailFast(false);
8181
executionContext.setErrors(test);
82-
for (JsonSchemaValidator schema : schemas) {
82+
for (Validator schema : schemas) {
8383
schema.validate(executionContext, node, rootNode, instanceLocation);
8484
if (test.isEmpty()) {
8585
valid = true;
@@ -105,7 +105,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode
105105

106106
@Override
107107
public void preloadJsonSchema() {
108-
for (final JsonSchemaValidator validator : schemas) {
108+
for (final Validator validator : schemas) {
109109
if (validator instanceof JsonValidator) {
110110
((JsonValidator) validator).preloadJsonSchema();
111111
} else if (validator instanceof JsonSchema) {

src/main/java/com/networknt/schema/JsonSchemaValidator.java renamed to src/main/java/com/networknt/schema/Validator.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,36 @@
2020
import com.networknt.schema.walk.Walker;
2121

2222
/**
23-
* Standard json validator interface, implemented by all validators and JsonSchema.
23+
* A processor that checks an instance node belonging to an instance document
24+
* against a schema.
2425
*/
25-
public interface JsonSchemaValidator extends Walker {
26+
public interface Validator extends Walker {
2627
/**
27-
* Validate the given JsonNode, the given node is the child node of the root node at given
28-
* data path.
29-
* @param executionContext ExecutionContext
30-
* @param node JsonNode
31-
* @param rootNode JsonNode
32-
* @param instanceLocation JsonNodePath
28+
* Validate the instance node which belongs to the instance document at the
29+
* instance location.
30+
*
31+
* @param executionContext the execution context
32+
* @param instanceNode the instance node being processed
33+
* @param instance the instance document that the instance node belongs
34+
* to
35+
* @param instanceLocation the location of the instance node being processed
3336
*/
34-
void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode,
37+
void validate(ExecutionContext executionContext, JsonNode instanceNode, JsonNode instance,
3538
JsonNodePath instanceLocation);
3639

3740
/**
3841
* This is default implementation of walk method. Its job is to call the
3942
* validate method if shouldValidateSchema is enabled.
4043
*/
4144
@Override
42-
default void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode,
45+
default void walk(ExecutionContext executionContext, JsonNode instanceNode, JsonNode instance,
4346
JsonNodePath instanceLocation, boolean shouldValidateSchema) {
44-
if (node == null) {
47+
if (instanceNode == null) {
4548
// Note that null is not the same as NullNode
4649
return;
4750
}
4851
if (shouldValidateSchema) {
49-
validate(executionContext, node, rootNode, instanceLocation);
52+
validate(executionContext, instanceNode, instance, instanceLocation);
5053
}
5154
}
5255

src/main/java/com/networknt/schema/walk/Walker.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
package com.networknt.schema.walk;
22

33
import com.fasterxml.jackson.databind.JsonNode;
4-
import com.networknt.schema.JsonSchemaValidator;
4+
import com.networknt.schema.Validator;
55
import com.networknt.schema.ExecutionContext;
66
import com.networknt.schema.JsonNodePath;
77

88
public interface Walker {
99
/**
10-
*
1110
* This method gives the capability to walk through the given JsonNode, allowing
1211
* functionality beyond validation like collecting information,handling
1312
* cross-cutting concerns like logging or instrumentation. This method also
1413
* performs the validation if {@code shouldValidateSchema} is set to true. <br>
1514
* <br>
16-
* {@link JsonSchemaValidator#walk(ExecutionContext, JsonNode, JsonNode, JsonNodePath, boolean)}
15+
* {@link Validator#walk(ExecutionContext, JsonNode, JsonNode, JsonNodePath, boolean)}
1716
* provides a default implementation of this method. However, validators that
1817
* parse sub-schemas should override this method to call walk method on those
1918
* sub-schemas.

0 commit comments

Comments
 (0)