@snaier/schema-js
v0.1.0
Published
Dependency-free JSON Schema (draft-07 subset) validator for @snaier/engine's SchemaValidator port
Readme
@snaier/schema-js
A dependency-free JSON Schema validator for the engine's SchemaValidator
port. It validates the document member of a task's inputSchema /
outputSchema against a draft-07 subset and reports every issue found as an
RFC 6901 JSON Pointer + message.
Why it exists
The engine's schema validation is a port — you can install any validator you like. This package is the zero-dependency default that ships nothing but the core subset a workflow contract needs, so a host that only validates task inputs and outputs does not have to pull in a full schema machinery.
Usage
import { createJsonSchemaValidator } from '@snaier/schema-js';
import { WorkflowExecutor } from '@snaier/engine';
const executor = new WorkflowExecutor({
definition,
expression: createJsEvaluator(),
platform: new NodePlatform(),
calls: NODE_CALL_HANDLERS,
schema: createJsonSchemaValidator(), // ← wire it in
});
// A task may then declare contracts:
// inputSchema: { document: { type: 'object', required: ['id'], ... }, format: 'json' }
// outputSchema: { document: { type: 'object' } }Supported keywords (draft-07 subset)
type,enum,constproperties,additionalProperties,requireditems(list & tuple form),additionalItemsallOf,anyOf,oneOf,not,if/then/else$ref— local refs into#/definitionsand#/$defsminimum/maximum/exclusiveMinimum/exclusiveMaximum/multipleOfminLength/maxLength/patternminItems/maxItems/uniqueItemsminProperties/maxPropertiesformat— lenient checks fordate-time,date,email,uri,uuid,ipv4,hostname
Anything not in this list (e.g. patternProperties, remote $ref) is ignored
by this validator, so the host remains the authority for richer schemas — use
a full validator like ajv for those.
Design
- Zero runtime dependencies, matching the project's lean ethos.
- Synchronous — it plugs directly into the engine's synchronous
SchemaValidatorport. - Reports every issue, each addressed by a JSON Pointer relative to the validated value.
