Package com.networknt.schema
Class JsonSchema
- java.lang.Object
-
- com.networknt.schema.BaseJsonValidator
-
- com.networknt.schema.JsonSchema
-
- All Implemented Interfaces:
JsonValidator
public class JsonSchema extends BaseJsonValidator
This is the core of json constraint implementation. It parses json constraint file and generates JsonValidators. The class is thread safe, once it is constructed, it can be used to validate multiple json data concurrently.
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,JsonValidator>
validators
-
Fields inherited from class com.networknt.schema.BaseJsonValidator
config
-
Fields inherited from interface com.networknt.schema.JsonValidator
AT_ROOT
-
-
Constructor Summary
Constructors Constructor Description JsonSchema(ValidationContext validationContext, com.fasterxml.jackson.databind.JsonNode schemaNode)
JsonSchema(ValidationContext validationContext, com.fasterxml.jackson.databind.JsonNode schemaNode, boolean suppressSubSchemaRetrieval)
JsonSchema(ValidationContext validationContext, String schemaPath, com.fasterxml.jackson.databind.JsonNode schemaNode, JsonSchema parent)
JsonSchema(ValidationContext validationContext, String schemaPath, com.fasterxml.jackson.databind.JsonNode schemaNode, JsonSchema parent, boolean suppressSubSchemaRetrieval)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonSchema
findAncestor()
com.fasterxml.jackson.databind.JsonNode
getRefSchemaNode(String ref)
Find the schema node for $ref attribute.JsonValidator
getRequiredValidator()
boolean
hasRequiredValidator()
String
toString()
Set<ValidationMessage>
validate(com.fasterxml.jackson.databind.JsonNode jsonNode, com.fasterxml.jackson.databind.JsonNode rootNode, String at)
Validate the given JsonNode, the given node is the child node of the root node at given data path.-
Methods inherited from class com.networknt.schema.BaseJsonValidator
buildValidationMessage, debug, equals, fetchSubSchemaNode, getNodeFieldType, getParentSchema, getSchemaNode, getSchemaPath, getValidatorType, greaterThan, lessThan, parseErrorCode, validate
-
-
-
-
Field Detail
-
validators
protected final Map<String,JsonValidator> validators
-
-
Constructor Detail
-
JsonSchema
public JsonSchema(ValidationContext validationContext, com.fasterxml.jackson.databind.JsonNode schemaNode)
-
JsonSchema
public JsonSchema(ValidationContext validationContext, String schemaPath, com.fasterxml.jackson.databind.JsonNode schemaNode, JsonSchema parent)
-
JsonSchema
public JsonSchema(ValidationContext validationContext, String schemaPath, com.fasterxml.jackson.databind.JsonNode schemaNode, JsonSchema parent, boolean suppressSubSchemaRetrieval)
-
JsonSchema
public JsonSchema(ValidationContext validationContext, com.fasterxml.jackson.databind.JsonNode schemaNode, boolean suppressSubSchemaRetrieval)
-
-
Method Detail
-
getRefSchemaNode
public com.fasterxml.jackson.databind.JsonNode getRefSchemaNode(String ref)
Find the schema node for $ref attribute.- Parameters:
ref
- String- Returns:
- JsonNode
-
findAncestor
public JsonSchema findAncestor()
-
validate
public Set<ValidationMessage> validate(com.fasterxml.jackson.databind.JsonNode jsonNode, com.fasterxml.jackson.databind.JsonNode rootNode, String at)
Description copied from interface:JsonValidator
Validate the given JsonNode, the given node is the child node of the root node at given data path.- Parameters:
jsonNode
- JsonNoderootNode
- JsonNodeat
- String- Returns:
- A list of ValidationMessage if there is any validation error, or an empty list if there is no error.
-
hasRequiredValidator
public boolean hasRequiredValidator()
-
getRequiredValidator
public JsonValidator getRequiredValidator()
-
-