ENSEMBLU SchemaGuard Β· axiom-language 2.0.0
Project Axiom Β· Perimeter Validation

SchemaGuard

You give it data and a schema. It returns a clear Result β€” valid data, or a plain-English reason why not. Never a crash.

Every payload crossing your boundary β€” API body, config file, upload β€” either matches the shape you expect, or it doesn’t.

SchemaGuard answers that in one handshake:

βœ“ Valid
Result.success β€” data is safe to use as-is.
βœ— Invalid
Result.failure β€” what failed, and where.

No exceptions thrown for β€œbad shape.” No half-processed data leaking through.

What it replaces

The usual way
  • Annotate a class; hope the framework wires it
  • Reflection scans objects at runtime
  • Bad data throws deep in unrelated code
  • Debug by chasing a stack trace
With SchemaGuard
  • Write the schema once as a plain .axiom file
  • No annotations, no reflection, no scanning
  • Bad data never throws β€” you get a Result
  • The failure message names the field and rule

How you actually use it (2.0.0)

Content is byte[] (or an already-parsed map). Three steps. That’s the whole interaction.

Primary path β€” raw bytes + built-in AxiomDopParser
final var result = SchemaGuard
        .checkContent(contentBytes)
        .basedOnSchemaInPath("user-profile")
        .withAxiomParser();
JSON body (e.g. HTTP request) β€” plug in JsonParser
final var data = SchemaGuard
        .checkContent(substance)   // substance = request body as byte[]
        .basedOnSchemaInPath("schemas/account_query_schema")
        .withParser(bytes -> JsonParser.take(bytes)
                .openBuffer()
                .ensureRootIsObject()
                .parseObject())
        .getOrThrow();
Already-parsed map β€” skip re-parse
final var result = SchemaGuard
        .checkContent(myPersistentMap)
        .basedOnSchemaInPath("user-profile")
        .withAxiomParser();
1

Hand it byte[] or a PersistentMap.

2

Name the schema file via basedOnSchemaInPath.

3

Get a Result β€” never a structural crash.

⚠️ Breaking Changes in 2.0.0
  • checkContent(String) is gone. Use checkContent(byte[]) or checkContent(PersistentMap).
  • withParser is now Function<byte[], PersistentMap<String, Object>>.

Writing a schema: the .axiom file

A schema is a plain file, not code. Drop it under schemas/, reference it by path β€” nothing to compile or annotate.

schemas/account_query_schema.axiom
{
  required: [status, limit]
  properties: {
    status: {
      type: string
      enum: [ACTIVE, INACTIVE, SUSPENDED, PENDING]
    }
    limit: {
      type: integer
      min: 1
      max: 1000
      description: Maximum records per fetch.
    }
  }
}

Part of axiom-language Β· depends on axiom-sovereign + axiom