# @isdk/match-ex-schema

> Ajv-backed JSON Schema plugin for @isdk/match-ex. Importing it registers AjvSchemaType as the engine's schema implementation, so JSON Schema expectations validate out of the box.

Latest version **0.1.2** (published 2026-09-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @isdk/match-ex-schema
pnpm add @isdk/match-ex-schema
yarn add @isdk/match-ex-schema
bun add @isdk/match-ex-schema
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2026-09-17 |
| First published | 2026-09-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 9.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Riceball LEE <snowyu.lee@gmail.com> |
| Maintainers | isdk |
| Keywords | match-ex, json-schema, ajv, validate, plugin, isdk |

## Links

- npm: https://www.npmjs.com/package/@isdk/match-ex-schema
- Repository: https://github.com/isdk/match-ex-schema.js
- Issues: https://github.com/isdk/match-ex-schema.js/issues
- npm.io page: https://npm.io/package/@isdk/match-ex-schema

## Dependencies (3)

- [ajv](https://npm.io/package/ajv.md) ^8.20.0
- [ajv-formats](https://npm.io/package/ajv-formats.md) ^3.0.1
- [ajv-keywords](https://npm.io/package/ajv-keywords.md) ^5.1.0

## Alternatives

- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads

## Recent versions

- 0.1.2 (latest) — 2026-09-17
- 0.1.1 — 2026-09-17

## README

# @isdk/match-ex-schema

> 【English|[中文](./README.cn.md)】
---

Ajv-backed JSON Schema plugin for [`@isdk/match-ex`](https://github.com/isdk/match-ex.js).

Importing this package registers `AjvSchemaType` as the engine's JSON Schema implementation, so JSON Schema expectations validate out of the box.

## What it enables

- Heuristic JSON Schema detection — plain-object expectations like `{ type: 'object', properties: { ... } }` are validated as schemas (no `$schema` key needed).
- Explicit validation via the `$schema` operator and `JsonSchemaType` instances.
- Compiled once per expectation instance (Ajv `compile`), with `strictSchema: false` for YAML-friendly schemas.
- All [ajv-keywords](https://github.com/ajv-validator/ajv-keywords) and [ajv-formats](https://github.com/ajv-validator/ajv-formats) keywords/formats enabled (`range`, `regexp`, `date-time`, `email`, ...).

## Usage

```ts
import { validate, ValidationContext } from '@isdk/match-ex'
import '@isdk/match-ex-schema'

const ctx = new ValidationContext({})

// Heuristic detection
await validate(
  { name: 'Alice', age: 30 },
  {
    type: 'object',
    properties: { name: { type: 'string' }, age: { type: 'number', range: [18, 99] } },
    required: ['name'],
  },
  ctx
)

// Explicit operator
await validate(actualValue, { $schema: { type: 'string', format: 'date-time' } }, ctx)
```

## Exports

| Export | Description |
|---|---|
| `AjvSchemaType` | The Ajv-backed `JsonSchemaType` subclass. Extends the engine's abstract base; usable as a host integration point (e.g. YAML tag types). |

Unregister by calling `setJsonSchemaType(null)` from `@isdk/match-ex`, or register a custom implementation to replace this one.

## Dependencies

`ajv`, `ajv-keywords`, `ajv-formats` — deliberately kept out of the `@isdk/match-ex` core so consumers that never validate schemas never load Ajv.

## License

MIT © Riceball Lee

---
_Source: https://npm.io/package/@isdk/match-ex-schema · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
