Interface JsonSchemaValidator


public interface JsonSchemaValidator
Interface for validating structured content against a JSON schema. This interface defines a method to validate structured content based on the provided output schema.
Author:
Christian Tzolov
  • Method Details

    • assertConforms

      default void assertConforms(String context, Map<String,Object> schema)
      Asserts that the given schema document is a structurally valid JSON Schema. Schemas without an explicit $schema declaration, or those that declare JSON Schema 2020-12, are validated against the 2020-12 meta-schema. Schemas that explicitly declare a different dialect are accepted without meta-schema validation. Throws IllegalArgumentException if validation fails. Silently returns on null schema. The default implementation delegates to validateSchema(java.util.Map<java.lang.String, java.lang.Object>).
      Parameters:
      context - human-readable description of the schema's location (used in error messages)
      schema - the schema document to validate, or null (no-op)
      Throws:
      IllegalArgumentException - if the schema is structurally invalid
    • validate

      JsonSchemaValidator.ValidationResponse validate(Map<String,Object> schema, Object structuredContent)
      Validates the structured content against the provided JSON schema.
      Parameters:
      schema - The JSON schema to validate against.
      structuredContent - The structured content to validate.
      Returns:
      A ValidationResponse indicating whether the validation was successful or not.
    • validateSchema

      default JsonSchemaValidator.ValidationResponse validateSchema(Map<String,Object> schema)
      Validates that the given schema document itself conforms to JSON Schema 2020-12 (SEP-1613). Schemas that declare an explicit non-2020-12 $schema dialect are skipped and considered valid. The default implementation is a no-op.
      Parameters:
      schema - the schema document to check
      Returns:
      a ValidationResponse indicating conformance