diff --git a/README.md b/README.md index ee3c1ab7d..65368f5fe 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ Please review [Contributing guidelines](./CONTRIBUTING.md) and [Code components] - [Frequently Asked Questions](./docs/faq.md) - [Using in browser](#using-in-browser) - [Content Security Policy](./docs/security.md#content-security-policy) +- [Using in ES5 environment](#using-in-es5-environment) - [Command line interface](#command-line-interface) - [API reference](./docs/api.md) - [Methods](./docs/api.md#ajv-constructor-and-methods) @@ -307,6 +308,19 @@ The browser bundle is available on [cdnjs](https://cdnjs.com/libraries/ajv). **Please note**: some frameworks, e.g. Dojo, may redefine global require in a way that is not compatible with CommonJS module format. In this case Ajv bundle has to be loaded before the framework and then you can use global `ajv` (see issue [#234](https://github.com/ajv-validator/ajv/issues/234)). +## Using in ES5 environment + +You need to: + +- recompile Typescript to ES5 target - it is set to 2018 in the bundled compiled code. +- generate ES5 validation code: + +```javascript +const ajv = new Ajv({code: {es5: true}}) +``` + +See [Advanced options](https://github.com/ajv-validator/ajv/blob/master/docs/api.md#advanced-options). + ## Command line interface CLI is available as a separate npm package [ajv-cli](https://github.com/ajv-validator/ajv-cli). It supports: diff --git a/lib/vocabularies/applicator/oneOf.ts b/lib/vocabularies/applicator/oneOf.ts index f34c2dc97..268c2376e 100644 --- a/lib/vocabularies/applicator/oneOf.ts +++ b/lib/vocabularies/applicator/oneOf.ts @@ -9,7 +9,11 @@ import {_, Name} from "../../compile/codegen" import {alwaysValidSchema} from "../../compile/util" import {SchemaCxt} from "../../compile" -export type OneOfError = ErrorObject<"oneOf", {passingSchemas: [number, number] | null}, AnySchema[]> +export type OneOfError = ErrorObject< + "oneOf", + {passingSchemas: [number, number] | null}, + AnySchema[] +> const error: KeywordErrorDefinition = { message: "should match exactly one schema in oneOf",