jsvrx-ajv
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

jsvrx-ajv

RxJS operators to validate/discriminate data objects using JSON Schema(s) and Ajv: Another JSON Schema Validator.

npm ajv npm bundle size Top Language MIT License

Install

npm i jsvrx-ajv

Usage

AjvDataValidtor is DataValidator interface implementation using Ajv.

For more information about DataValidation interface and usage examples see jsvrx.

Create a new AjvDataValidator instance using ajv.Options or pass an ajv instace as the constructor's parameter.

import { AjvDataValidator } from 'jsvrx-ajv';
const dv = new AjvDataValidator({ coerceTypes: true })

import ajv from 'ajv';
const dv = new AjvDataValidator(new ajv())

AjvDataValidator.discriminate(ids: JSONSchemaID[], unk?: JSONSchemaID) implementation doesn't provide optimized validation for multiple JSON Schemas. It executes single JSON Schema validation attempts in ids array order. Fill the ids array accordingly.

ValidationError.e holds ajv.ValidateFunction.errors for the validate error and array of ajv.ValidateFunction.errors for the discriminate error.

Package Sidebar

Install

npm i jsvrx-ajv

Weekly Downloads

3

Version

2.0.0

License

MIT

Unpacked Size

7.83 kB

Total Files

6

Last publish

Collaborators

  • gadicuz