This repository has been archived by the owner on Dec 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d4b0643
commit 96ccdf0
Showing
2 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,41 @@ | ||
# ajv-async | ||
Managing and detecting async validation mode in Ajv - JSON-Schema validator | ||
Configure async validation mode in [Ajv](https://github.com/epoberezkin/ajv) - JSON-Schema validator | ||
|
||
[![npm version](https://badge.fury.io/js/ajv-async.svg)](https://www.npmjs.com/package/ajv-async) | ||
[![Gitter](https://img.shields.io/gitter/room/ajv-validator/ajv.svg)](https://gitter.im/ajv-validator/ajv) | ||
|
||
## Install | ||
|
||
```shell | ||
npm install ajv-async | ||
``` | ||
|
||
|
||
## Usage | ||
|
||
The code below configures async mode in Ajv instance to use the best async mode (async functions or generators) available in the current environment with/without transpilation. If transpilation is required, you should install [nodent](https://github.com/MatAtBread/nodent) or [regenerator](https://github.com/facebook/regenerator), ajv-async doesn't install them. | ||
|
||
```javascript | ||
var Ajv = require('ajv'); | ||
var setupAsync = require('ajv-async'); | ||
|
||
var ajv = setupAsync(new Ajv); | ||
``` | ||
|
||
`async` and/or `transpile` options can be passed to Ajv to enable a specific async/transpilation mode. See [Ajv docs](https://github.com/epoberezkin/ajv#asynchronous-validation) for more information. | ||
|
||
|
||
## Using in browser | ||
|
||
At the moment Ajv already includes nodent and regenerators bundles. You still need to use this package, unless you manually set `async` option and explicitely pass `processCode` option. `transpile` option support requires using this package. | ||
|
||
If you build this package with your code with Webpack, it will log warnings because this package uses optional dependencies. To suppress these warnings use [IgnorePlugin](https://webpack.github.io/docs/list-of-plugins.html#ignoreplugin): | ||
|
||
```javascript | ||
new IgnorePlugin(/regenerator|nodent/, /ajv-async/) | ||
``` | ||
|
||
|
||
## License | ||
|
||
[MIT](https://github.com/epoberezkin/ajv-async/blob/master/LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters