Class JsonSchemaIdValidator.DefaultJsonSchemaIdValidator

java.lang.Object
com.networknt.schema.JsonSchemaIdValidator.DefaultJsonSchemaIdValidator
All Implemented Interfaces:
JsonSchemaIdValidator
Enclosing interface:
JsonSchemaIdValidator

public static class JsonSchemaIdValidator.DefaultJsonSchemaIdValidator extends Object implements JsonSchemaIdValidator
Implementation of JsonSchemaIdValidator.

Note that this does not strictly follow the specification.

This allows an $id that isn't an absolute-IRI on the root schema, but it must resolve to an absolute-IRI given a base-IRI.

This also allows non-empty fragments.

  • Constructor Details

    • DefaultJsonSchemaIdValidator

      public DefaultJsonSchemaIdValidator()
  • Method Details

    • validate

      public boolean validate(String id, boolean rootSchema, SchemaLocation schemaLocation, SchemaLocation resolvedSchemaLocation, ValidationContext validationContext)
      Description copied from interface: JsonSchemaIdValidator
      Validates if the $id value is valid.
      Specified by:
      validate in interface JsonSchemaIdValidator
      Parameters:
      id - the $id or id
      rootSchema - true if this is a root schema
      schemaLocation - the schema location
      resolvedSchemaLocation - the schema location after resolving with the id
      validationContext - the validation context for instance to get the meta schema
      Returns:
      true if valid
    • startsWithSlash

      protected boolean startsWithSlash(String id)
    • isFragment

      protected boolean isFragment(String id)
    • hasNoContext

      protected boolean hasNoContext(SchemaLocation schemaLocation)
    • isAbsoluteIri

      protected boolean isAbsoluteIri(String iri)