Class AbstractKeywordValidator

java.lang.Object
com.networknt.schema.keyword.AbstractKeywordValidator
All Implemented Interfaces:
KeywordValidator, Validator, Walker
Direct Known Subclasses:
BaseKeywordValidator

public abstract class AbstractKeywordValidator extends Object implements KeywordValidator
  • Field Details

    • schemaNode

      protected final com.fasterxml.jackson.databind.JsonNode schemaNode
    • schemaLocation

      protected final SchemaLocation schemaLocation
  • Constructor Details

    • AbstractKeywordValidator

      public AbstractKeywordValidator(String keyword, com.fasterxml.jackson.databind.JsonNode schemaNode, SchemaLocation schemaLocation)
      Constructor.
      Parameters:
      keyword - the keyword
      schemaNode - the schema node
      schemaLocation - the schema location
    • AbstractKeywordValidator

      public AbstractKeywordValidator(Keyword keyword, com.fasterxml.jackson.databind.JsonNode schemaNode, SchemaLocation schemaLocation)
      Constructor.
      Parameters:
      keyword - the keyword
      schemaNode - the schema node
      schemaLocation - the schema location
  • Method Details

    • getSchemaLocation

      public SchemaLocation getSchemaLocation()
      Description copied from interface: Validator
      The schema location is the canonical URI of the schema object plus a JSON Pointer fragment indicating the subschema that produced a result. In contrast with the evaluation path, the schema location MUST NOT include by-reference applicators such as $ref or $dynamicRef.
      Specified by:
      getSchemaLocation in interface Validator
      Returns:
      the schema location
    • getKeyword

      public String getKeyword()
      Description copied from interface: KeywordValidator
      The keyword of the validator.
      Specified by:
      getKeyword in interface KeywordValidator
      Returns:
      the keyword
    • getSchemaNode

      public com.fasterxml.jackson.databind.JsonNode getSchemaNode()
      The schema node used to create the validator.
      Returns:
      the schema node
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • collectAnnotations

      protected boolean collectAnnotations(ExecutionContext executionContext)
      Determine if annotations should be reported.
      Parameters:
      executionContext - the execution context
      Returns:
      true if annotations should be reported
    • collectAnnotations

      protected boolean collectAnnotations(ExecutionContext executionContext, String keyword)
      Determine if annotations should be reported.
      Parameters:
      executionContext - the execution context
      keyword - the keyword
      Returns:
      true if annotations should be reported
    • putAnnotation

      protected void putAnnotation(ExecutionContext executionContext, Consumer<Annotation.Builder> customizer)
      Puts an annotation.
      Parameters:
      executionContext - the execution context
      customizer - to customize the annotation
    • hasAdjacentKeywordInEvaluationPath

      protected boolean hasAdjacentKeywordInEvaluationPath(ExecutionContext executionContext, String keyword)
      Determines if the keyword exists adjacent in the evaluation path.

      This does not check if the keyword exists in the current meta schema as this can be a cross-draft case where the properties keyword is in a Draft 7 schema and the unevaluatedProperties keyword is in an outer Draft 2020-12 schema.

      The fact that the validator exists in the evaluation path implies that the keyword was valid in whatever meta schema for that schema it was created for.

      Parameters:
      keyword - the keyword to check
      Returns:
      true if found
    • hasUnevaluatedItemsInEvaluationPath

      protected boolean hasUnevaluatedItemsInEvaluationPath(ExecutionContext executionContext)
    • hasUnevaluatedPropertiesInEvaluationPath

      protected boolean hasUnevaluatedPropertiesInEvaluationPath(ExecutionContext executionContext)