@osirisjson/core
v0.1.0
Published
OSIRIS JSON Toolbox - core validation engine
Maintainers
Readme
@osirisjson/core
Validation engine for OSIRIS JSON documents.
Part of the osiris-toolbox monorepo.
Installation
npm install @osirisjson/coreUsage
import { validate } from '@osirisjson/core';
const diagnostics = validate(document);
// or with options
const diagnostics = validate(document, { profile: 'strict' });
if (diagnostics.length === 0) {
console.log('Document is valid');
} else {
for (const d of diagnostics) {
console.log(`[${d.severity}] ${d.code} - ${d.message}`);
}
}Validation profiles
| Profile | Stages run | Description |
|-----------|---------------------|--------------------------------------|
| basic | Structural only | Schema conformance check |
| default | Structural + Semantic | Adds referential integrity checks |
| strict | All three stages | Adds domain-specific rule checks |
The default profile is default.
API
validate(document, options?): Diagnostic[]
Validates an OSIRIS JSON document and returns an array of diagnostics. Returns an empty array if the document is valid.
Options:
| Option | Type | Default | Description |
|-----------|---------------------|-------------|------------------------------------|
| profile | ValidationProfile | 'default' | Validation strictness level |
lookupCode(code): CodeEntry | undefined
Look up a diagnostic code by its identifier (e.g. 'V-DOC-001').
getRegistry(): Map<string, CodeEntry>
Returns the full diagnostic code registry.
Requirements
- Node.js >= 20.0.0
