You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+44-42Lines changed: 44 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,13 +27,14 @@ Supports [JSON](http://json.org/), [JSON5](http://json5.org/), and [YAML](http:/
27
27
npm install -g ajv-cli
28
28
```
29
29
30
-
## JSON schema version
30
+
## JSON schema language and version
31
31
32
-
Parameter `--spec` can be used with all commands (other than help) to define which JSON schema language is used:
32
+
Parameter `--spec` can be used with all commands (other than help) to choose JSON schema language:
33
33
34
34
-`--spec=draft7` (default) - support JSON Schema draft-07 (uses `import Ajv from "ajv"`)
35
35
-`--spec=draft2019` - support JSON Schema draft-2019-09 (uses `import Ajv from "ajv/dist/2019"`)
36
-
-`--spec=jtd` - support JSON Type Definition (uses `import Ajv from "ajv/dist/jtd"`)
36
+
-`--spec=draft2020` - support JSON Schema draft-2020-12 (uses `import Ajv from "ajv/dist/2020"`)
37
+
-`--spec=jtd` - support [JSON Type Definition](https://ajv.js.org/json-type-definition.html) (uses `import Ajv from "ajv/dist/jtd"`)
37
38
38
39
## Commands
39
40
@@ -91,7 +92,7 @@ Multiple meta-schemas can be passed, as in `-r` parameter.
91
92
You can pass module(s) that define custom keywords/formats. The modules should export a function that accepts Ajv instance as a parameter. The file name should start with ".", it will be resolved relative to the current folder. The package name can also be passed - it will be used in require as is.
92
93
These modules can be written in TypeScript if you have `ts-node` installed.
93
94
94
-
For example, you can use `-c ajv-keywords` to add all keywords from [ajv-keywords](https://github.com/epoberezkin/ajv-keywords) package or `-c ajv-keywords/keywords/typeof` to add only typeof keyword.
95
+
For example, you can use `-c ajv-keywords` to add all keywords from [ajv-keywords](https://github.com/ajv-validator/ajv-keywords) package or `-c ajv-keywords/keywords/typeof` to add only typeof keyword.
95
96
96
97
#### Options
97
98
@@ -111,7 +112,7 @@ For example, you can use `-c ajv-keywords` to add all keywords from [ajv-keyword
111
112
112
113
This command validates and compiles schema without validating any data.
113
114
114
-
It can be used to check that the schema is valid and to create a standalone module exporting validation function (using [ajv-pack](https://github.com/epoberezkin/ajv-pack)).
115
+
It can be used to check that the schema is valid and to create a standalone module exporting validation function(s).
115
116
116
117
```sh
117
118
ajv compile -s schema
@@ -147,9 +148,9 @@ This command also supports parameters `-r`, `-m` and `-c` as in [validate](#vali
147
148
148
149
### Migrate schemas
149
150
150
-
This command validates and migrates schema from JSON Schema draft-04 to JSON Schema draft-07 or draft-2019-09 using [json-schema-migrate](https://github.com/epoberezkin/json-schema-migrate) package.
151
+
This command validates and migrates schema from JSON Schema draft-04 to draft-07, draft-2019-09 or draft-2020-12 using [json-schema-migrate](https://github.com/ajv-validator/json-schema-migrate) package.
151
152
152
-
The [version of JSON Schema](#json-schema-version) is determined by `--spec` parameter (only `"draft7"`or `"draft2019"`).
153
+
The [version of JSON Schema](#json-schema-version) is determined by `--spec` parameter (only `"draft7"`, `"draft2019"`or `"draft2020"`).
|`--strict-tuples=`| throw on (`true`) or ignore (`false`) [strict tuples](https://github.com/ajv-validator/ajv/blob/master/docs/strict-mode.md#prohibit-unconstrained-tuples) restrictions (the default is to log) |
211
-
|`--strict-types=`| throw on (`true`) or ignore (`false`) [strict types](https://github.com/ajv-validator/ajv/blob/master/docs/strict-mode.md#strict-types) restrictions (the default is to log) |
212
-
|`--allow-matching-properties`| allow `properties`[matching patterns](https://github.com/ajv-validator/ajv/blob/master/docs/strict-mode.md#prohibit-overlap-between-properties-and-patternproperties-keywords) in `patternProperties`|
|`--use-defaults`| replace missing properties/items with the values from default keyword |
224
-
|`--coerce-types`| change type of data to match type keyword |
225
-
| Advanced |
226
-
|`--multiple-of-precision`| precision of multipleOf, pass integer number |
227
-
|`--messages=false`| do not include text messages in errors |
228
-
|`--loop-required=`| max size of `required` to compile to expression (rather than to loop) |
229
-
|`--loop-enum=`| max size of `enum` to compile to expression (rather than to loop) |
230
-
|`--own-properties`| only validate own properties (not relevant for JSON, but can have effect for JavaScript objects) |
231
-
| Code generation |
232
-
|`--code-es5`| generate ES5 code |
233
-
|`--code-lines`| generate multi-line code |
234
-
|`--code-optimize=`| disable optimization (`false`) or number of optimization passes (1 pass by default) |
235
-
|`--code-formats=`| code to require formats object (only needed if you generate standalone code and do not use [ajv-formats](https://github.com/ajv-validator/ajv-formats)) |
204
+
You can pass the following [Ajv options](https://ajv.js.org/options.html):
205
+
206
+
| Option | Description |
207
+
| ------ | ----------- |
208
+
| Strict mode |
209
+
|`--strict=`|`true`/`false`/`log` - set all [strict mode](https://ajv.js.org/strict-mode.html) restrictions |
210
+
|`--strict-schema=`| log on (`log`) or ignore (`false`) [strict ](https://ajv.js.org/strict-mode.html#prohibit-ignored-keywords) restrictions (the default is to log) |
211
+
|`--strict-tuples=`| throw on (`true`) or ignore (`false`) [strict schema](https://ajv.js.org/strict-mode.html#prohibit-unconstrained-tuples) restrictions (the default is to throw) |
212
+
|`--strict-types=`| throw on (`true`) or ignore (`false`) [strict types](https://ajv.js.org/strict-mode.html#strict-types) restrictions (the default is to log) |
213
+
|`--strict-required=`| throw on (`true`) or log (`log`) [required properties](https://ajv.js.org/strict-mode.html#defined-required-properties) restrictions (the default is to ignore) |
214
+
|`--allow-matching-properties`| allow `properties`[matching patterns](https://ajv.js.org/strict-mode.html#overlap-between-properties-and-patternproperties-keywords) in `patternProperties`|
|`--use-defaults`| replace missing properties/items with the values from default keyword |
226
+
|`--coerce-types`| change type of data to match type keyword |
227
+
| Advanced |
228
+
|`--multiple-of-precision`| precision of multipleOf, pass integer number |
229
+
|`--messages=false`| do not include text messages in errors |
230
+
|`--loop-required=`| max size of `required` to compile to expression (rather than to loop) |
231
+
|`--loop-enum=`| max size of `enum` to compile to expression (rather than to loop) |
232
+
|`--own-properties`| only validate own properties (not relevant for JSON, but can have effect for JavaScript objects) |
233
+
| Code generation |
234
+
|`--code-es5`| generate ES5 code |
235
+
|`--code-lines`| generate multi-line code |
236
+
|`--code-optimize=`| disable optimization (`false`) or number of optimization passes (1 pass by default) |
237
+
|`--code-formats=`| code to require formats object (only needed if you generate standalone code and do not use [ajv-formats](https://github.com/ajv-validator/ajv-formats)) |
236
238
237
239
Options can be passed using either dash-case or camelCase.
238
240
239
-
See [Ajv Options](https://github.com/ajv-validator/ajv/blob/master/docs/api.md#options) for more information.
241
+
See [Ajv Options](https://ajv.js.org/options.html) for more information.
240
242
241
243
## Version History
242
244
243
-
See https://github.com/jessedc/ajv-cli/releases
245
+
See https://github.com/ajv-validator/ajv-cli/releases
0 commit comments