Class 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.
    • 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
      • 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 - JsonNode
        rootNode - JsonNode
        at - 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()