Class SchemaValidation

java.lang.Object
com.babelqueue.schema.SchemaValidation

public final class SchemaValidation extends Object
Optional per-URN data schema validation for a babelqueue producer or consumer (ADR-0024). A SchemaProvider supplies a JSON Schema for a message URN — typically built from a babelqueue-registry registry.json — and the message's data is validated against it. It is opt-in: a URN with no registered schema is never validated.

The Java mirror of the Go schema.Check/schema.Wrap helpers.

  • Method Details

    • check

      public static String check(SchemaProvider provider, String urn, Map<String,Object> data)
      The first data violation for (urn, data), or null when it is valid or when no schema is registered for the URN (opt-in). For producer-side branching.
      Parameters:
      provider - the schema source
      urn - the message URN
      data - the message data
      Returns:
      the first violation, or null
    • validate

      public static void validate(SchemaProvider provider, String urn, Map<String,Object> data)
      Validate (urn, data) against its registered schema, throwing otherwise. The producer-side guard; call it before publishing.
      Parameters:
      provider - the schema source
      urn - the message URN
      data - the message data
      Throws:
      InvalidPayloadException - when the data does not match the URN's schema
    • wrap

      public static Handler wrap(SchemaProvider provider, Handler handler)
      Returns handler wrapped to validate each message's data against its URN's schema before the handler runs (consumer-side safety net).
      Parameters:
      provider - the schema source
      handler - the handler to guard
      Returns:
      the wrapped handler