Skip to content

Commit 05c6795

Browse files
committed
update help and docs
1 parent d001716 commit 05c6795

2 files changed

Lines changed: 63 additions & 45 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,10 @@ You can pass the following [Ajv options](https://github.com/ajv-validator/ajv/bl
222222
| `--loop-enum=` | max size of `enum` to compile to expression (rather than to loop) |
223223
| `--own-properties` | only validate own properties (not relevant for JSON, but can have effect for JavaScript objects) |
224224
| Code generation |
225-
| `code.es5` | generate ES5 code |
226-
| `code.lines` | generate multi-line code |
227-
| `code.optimize=` | disable optimization (`false`) or number of optimization passes (1 pass by default) |
228-
| `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)) |
225+
| `--code.es5` | generate ES5 code |
226+
| `--code.lines` | generate multi-line code |
227+
| `--code.optimize=` | disable optimization (`false`) or number of optimization passes (1 pass by default) |
228+
| `--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)) |
229229

230230
Options can be passed using either dash-case or camelCase.
231231

src/commands/help.ts

Lines changed: 59 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ function mainHelp(): void {
4444
_helpCompile()
4545
_helpMigrate()
4646
_helpTest()
47+
schemaSpecOption()
4748
console.log(`
4849
More information:
4950
ajv help validate
@@ -52,6 +53,14 @@ More information:
5253
ajv help test`)
5354
}
5455

56+
function schemaSpecOption(): void {
57+
console.log(`
58+
options:
59+
--spec= JSON schema specification to use
60+
draft7 JSON Schema draft-07 (default)
61+
draft2019 JSON Schema draft-2019-09`)
62+
}
63+
5564
function helpValidate(): void {
5665
_helpValidate()
5766
console.log(`
@@ -66,9 +75,9 @@ parameters
6675
glob should be enclosed in double quotes
6776
-c module(s) should export a function that accepts Ajv instance as parameter
6877
(file path should start with ".", otherwise used as require package)
69-
.json extension can be omitted (but should be used in globs)
70-
71-
options:
78+
.json extension can be omitted (but should be used in globs)`)
79+
schemaSpecOption()
80+
console.log(`
7281
--errors= error reporting format ("js" by default)
7382
--changes= log changes in data after validation ("no" by default)
7483
js JavaScript object
@@ -97,11 +106,12 @@ parameters
97106
-o output file for compiled validation function
98107
99108
-s, -r, -m, -c can be globs and can be used multiple times
100-
If option -o is used only one schema can be compiled
101-
glob should be enclosed in double quotes
109+
With option -o multiple schemas will be exported using $ids as export names
110+
Glob should be enclosed in double quotes
102111
-c module(s) should export a function that accepts Ajv instance as parameter
103112
(file path should start with ".", otherwise used as require package)
104113
.json extension can be omitted (but should be used in globs)`)
114+
schemaSpecOption()
105115
helpAjvOptions()
106116
}
107117

@@ -116,25 +126,24 @@ function helpMigrate(): void {
116126
_helpMigrate()
117127
console.log(`
118128
parameters
119-
-s JSON schema(s) to migrate to draft-06 (required)
129+
-s JSON schema(s) to migrate to draft-07 or draft-2019-09 (required)
120130
-o output file for migrated schema (only allowed for a single schema)
121131
122132
-s can be glob and can be used multiple times
123133
If option -o is used only one schema can be migrated
124134
glob should be enclosed in double quotes
125-
.json extension can be omitted (but should be used in globs)
126-
127-
options:
128-
--v5 migrate schema as v5 if $schema is not specified
135+
.json extension can be omitted (but should be used in globs)`)
136+
schemaSpecOption()
137+
console.log(`
129138
--indent=<N> indentation in migrated schema JSON file, 4 by default
130139
--validate-schema=false skip schema validation`)
131140
}
132141

133142
function _helpMigrate(): void {
134143
console.log(`
135-
Migrate schema(s) to draft-06
144+
Migrate schema(s) to draft-07 or draft-2019-09
136145
ajv migrate -s schema[.json] -o migrated_schema.json
137-
ajv migrate -s "schema*.json`)
146+
ajv migrate -s "schema*.json"`)
138147
}
139148

140149
function helpTest(): void {
@@ -153,9 +162,9 @@ parameters
153162
-c module(s) should export a function that accepts Ajv instance as parameter
154163
(file path should start with ".", otherwise used as require package)
155164
.json extension can be omitted (but should be used in globs)
156-
--valid=false can be used instead of --invalid
157-
158-
options:
165+
--valid=false can be used instead of --invalid`)
166+
schemaSpecOption()
167+
console.log(`
159168
--errors= error reporting
160169
js JavaScript object (default)
161170
json JSON format
@@ -175,37 +184,36 @@ Test data validation result
175184
function helpAjvOptions(): void {
176185
console.log(`
177186
Ajv options (see https://github.com/epoberezkin/ajv#options):
178-
--data use $data references
187+
--strict=false disable strict mode
179188
180-
--all-errors collect all errors
189+
--strict-tuples= unconstrained tuples
190+
true throw exception
191+
false allow
192+
log log warning
193+
194+
--strict-types= union or unspecified types
195+
true throw exception
196+
false allow
197+
log log warning
181198
182-
--unknown-formats= handling of unknown formats
183-
true throw exception during schema compilation (default)
184-
<string> allowed unknown format name, multiple names can be used
199+
--allow-matching-properties allow "properties" matching patterns in "patternProperties"
185200
186-
--json-pointers report data paths as JSON pointers
201+
--allow-union-types allow union type keyword
187202
188-
--unique-items=false do not validate uniqueItems keyword
203+
--validate-formats=false disable format validation
189204
190-
--unicode=false count unicode pairs as 2 characters
205+
--data use $data references
191206
192-
--format= format validation mode
193-
fast using regex (default)
194-
full using functions
207+
--all-errors collect all errors
195208
196-
--schema-id= (by default both IDs will be used)
197-
$id use $id
198-
id use id
209+
--verbose include schema and data in errors
199210
200-
--extend-refs= validation of other keywords when $ref is present in the schema
201-
ignore ignore other keywords (default)
202-
fail throw exception (recommended)
203-
true validate all keywords
211+
--comment log schema "$comment"s
204212
205-
--missing-refs= handling missing referenced schemas
206-
true fail schema compilation (default)
207-
ignore log error and pass validation
208-
fail log error and fail validation if ref is used
213+
--inline-refs= referenced schemas compilation mode
214+
true inline $ref code when possible
215+
false always compile $ref as a function call
216+
<number> inline $ref code up to this number of keywords
209217
210218
--remove-additional= remove additional properties
211219
all remove all additional properties
@@ -218,9 +226,19 @@ Ajv options (see https://github.com/epoberezkin/ajv#options):
218226
219227
--multiple-of-precision=N pass integer number
220228
221-
--error-data-path= data path in errors of required, additionalProperties and dependencies
222-
object point to object (default)
223-
property point to property
229+
--messages=false do not include text messages in errors
230+
231+
--loop-required= max size of "required to compile to expression (rather than to loop)
232+
233+
--loop-enum= max size of "enum" to compile to expression (rather than to loop)
234+
235+
--own-properties only validate own properties (not relevant for JSON, but can have effect for JavaScript objects)
236+
237+
--code.es5 generate ES5 code
238+
239+
--code.lines generate multi-line code
224240
225-
--messages=false do not include text messages in errors`)
241+
--code.optimize= code optimization
242+
false disable
243+
<number> number of optimization passes (1 pass by default)`)
226244
}

0 commit comments

Comments
 (0)