Skip to content

Commit

Permalink
docs: move "using in ES5 env" to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
epoberezkin authored and andriyl committed Jun 16, 2021
1 parent 9ec8301 commit 7b0acbc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 0 additions & 6 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ This problem is related to the problem explained above - properties treated as a

See the example in [Filtering Data](https://github.com/ajv-validator/ajv#filtering-data) section of readme.

#### Using ajv v7 in ES5 environments

As of ajv v7, to support pre-ES6 env you will need to:
* recompile Typescript to es5 target - it's set to 2018 in the bundled compiled code.
* generate es5 code `(new Ajv({code:{es5:true}}))`, refs [Advanced options](https://github.com/ajv-validator/ajv/blob/master/docs/api.md#advanced-options).

## Generating schemas with resolved references (\$ref)

See [#22](https://github.com/ajv-validator/ajv/issues/22), [#125](https://github.com/ajv-validator/ajv/issues/125), [#146](https://github.com/ajv-validator/ajv/issues/146), [#228](https://github.com/ajv-validator/ajv/issues/228), [#336](https://github.com/ajv-validator/ajv/issues/336), [#454](https://github.com/ajv-validator/ajv/issues/454).
Expand Down
6 changes: 5 additions & 1 deletion lib/vocabularies/applicator/oneOf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 7b0acbc

Please sign in to comment.