jsvrx-ajv v2.0.0
jsvrx-ajv
RxJS operators to validate/discriminate data objects using JSON Schema(s) and Ajv: Another JSON Schema Validator.
Install
npm i jsvrx-ajvUsage
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.