/** * @module json-schema */ /** @pratico/json-schema */ import { JsonSchema } from './draft-06'; import * as ajv from 'ajv'; /** * Represents the config passed into the PraticoValidator * Allows to define the schemas, keywords, formats and configuration of coerceTypes and allErrors * @export * @interface PraticoJsonSchemaValidatorConfig */ export interface ValidatorConfig { /** * Set of schemas which will be loaded into Ajv * * @type {JsonSchema[]} * @memberof PraticoJsonSchemaValidatorConfig */ schemas: JsonSchema[]; /** * Set of custom keywords which will be used to validate data * * @type {{ [name: string]: ajv.KeywordDefinition }} * @memberof PraticoJsonSchemaValidatorConfig */ keywords?: { [name: string]: ajv.KeywordDefinition; }; /** * Set of custom formats which will be loaded into Ajv * * @type {({ [name: string]: ajv.FormatDefinition | ajv.FormatValidator })} * @memberof PraticoJsonSchemaValidatorConfig */ formats?: { [name: string]: ajv.FormatDefinition | ajv.FormatValidator; }; /** * Defines if ajv should convert the values of properties to the expected types * * @type {boolean} * @memberof PraticoJsonSchemaValidatorConfig */ coerceTypes?: boolean; /** * Defines if ajv should kepp running until the end. * if false, the ajv will stop when it finds the first error * @type {boolean} * @memberof PraticoJsonSchemaValidatorConfig */ allErrors?: boolean; }