-
Notifications
You must be signed in to change notification settings - Fork 16
/
ajv.javascript.txt
571 lines (483 loc) · 34.5 KB
/
ajv.javascript.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
AJV
ALTERNATIVES ==> #See JSON schema
VERSION ==> #8.12.0
#Browser, Node.js or CLI
SUMMARY ==> #Validates JSON schema
#Features:
# - good JSON schema support
# - good JSON references support
# - meta-schema validation
# - can modify input: default values, transtyping, removing extra properties
# - flexible custom formats|rules, including async validation
# - detailed, human-friendly, i18n'd errors
# - great speed, caching
NOTATION ==> #The following notation takes as example:
# - schema: { properties: { world: { properties: { hello: { minimum: 1 } } } } }
# - data: { world: { hello: 2 } }
SCHEMA_ID #SCHEMA.$id
#Only available if direct call to AJV.add[Meta]Schema()
#Can use AOPTS.schemaId '$id' (def), 'id' or 'auto' for backward compatiblity with previous
#versions of JSON schema
SCHEMA_VAL #1
PARENT_SCHEMA #{ minimum: 1 }
DATA_VAL #2
PARENT_DATA #{ hello: 2 }
ROOT_DATA #{ world: { hellow: 2 } }
DATA_PATH #'.world.hello'
DATA_VAR #'hello'
SCHEMA_PATH #'#/properties/world/properties/hello/minimum'
/=+===============================+=\
/ : : \
)==: BASIC :==(
\ :_______________________________: /
\=+===============================+=/
PHASES ==> #Schema validation: SCHEMA validated against its meta-schema
#Compilation: SCHEMA transformed in a fast function (VALIDATE)
#Data validation: data validated against VALIDATE
new Ajv([AOPTS]) #
AJV.add[Meta]Schema #Validate a schema, but does not compile it
(SCHEMA[_ARR][,'SCHEMA_ID'])->AJV #Can overwrite SCHEMA.$id with SCHEMA_ID
AOPTS.schemas|meta SCHEMA[_ARR] #Difference with "Meta":
# - mostly semantics, but there are few differences of behavior
# - metaschemas are global, so should do AJV.validateSchema(OBJ) instead of
# AJV.validate(SCHEMA, OBJ)
AJV.validateSchema(OBJ)->BOOL #
AOPTS.validateSchema #Validate schema against its meta-schema
#Throws exception if invalid if true (def), logs only if "log", do nothing if false.
#Meta-schema is defined by either:
# - SCHEMA.schema
# - KOPTS.metaSchema SCHEMA (not for validate())
AJV.getSchema('SCHEMA_ID')
->VALIDATE #
AJV.removeSchema
(SCHEMA|'SCHEMA_ID'|REGEXP)->AJV #REGEXP matches schema.$id or SCHEMA_ID
AJV.compile(SCHEMA)->VALIDATE #Validate a schema + compile
VALIDATE.schema #SCHEMA
VALIDATE(OBJ)->BOOL #
AJV.validate #Same as AJV.compile(SCHEMA)(OBJ)->BOOL
(SCHEMA|'SCHEMA_ID', OBJ)->BOOL #Will use AJV.errors instead of VALIDATE.errors
AOPTS.addUsedSchema #If true (def), compile|validate() call addSchema() under the hood.
/=+===============================+=\
/ : : \
)==: STANDALONE :==(
\ :_______________________________: /
\=+===============================+=/
import 'ajv/dist/standalone' #STANDALONE
STANDALONE(AJV[, VALIDATE]) #Returns module CODE that exports VALIDATE, but can be used without initializing AJV library
->'CODE' #nor compiling schemas, i.e. faster.
#Ajv must still be available runtime (or bundle-time).
#Def VALIDATE: all schemas added to AJV
#Has less features that full-blown library:
# - no validate|compile custom keyword (only macro|inline)
# - no recursive JSON reference
# - AOPTS.allErrors always true
# - no AOPTS.verbose
# - lots of others
AOPTS.code.source #BOOL (def: false). Must be true
AOPTS.code.es5 #BOOL (def: false). Output ES5 code
AOPTS.code.esm #BOOL (def: false). Output ESM vs CommonJS code
AOPTS.code.lines #BOOL (def: false). Output includes line breaks, for prettification
AOPTS.code.process
('CODE'[, SCHEMA])->'CODDE' #Maps code to output
AOPTS.code.optimize #NUM, true (def, same as 1) or false (same as 0)
#Number of minification passes. 1 is usually enough, and reduce file size by ~10%.
AOPTS.code.formats #Custom format
#Value must be AJV._`require(PATH_TO_FORMATS)`
AOPTS.code.regexp #Customize REGEXP matching
/=+===============================+=\
/ : : \
)==: CLI :==(
\ :_______________________________: /
\=+===============================+=/
ajv ... ##Module "ajv-cli" (5.0.0)
--strict*
--allow*
--validate-formats
--data
--all-errors
--verbose
--comment
--inline-refs=STR
--remove-additional=STR
--use-defaults
--coerce-types
--multiple-of-precision=NUM
--messages=BOOL
--loop-required
--loop-enum
--own-properties
--code* ##See AOPTS. Can also be camelCase
--spec=STR ##Among: "jtd" (JSON types) or "draft7" (def), "draft2019", "draft2020" (JSON schema)
-s SCHEMA
-m SCHEMA ##Like AOPTS.schema|meta. SCHEMA can contain globbing (escaped)
-c MODULE|'MODULE_PATH' ##Is FUNC(AJV)->AJV, which can e.g. call AJV.addKeyword|addFormat()
##MODULE_PATH must be relative
##Can be 'ajv-keywords[/keywords/KEYWORD]'
-r SCHEMA ##Files that can be used for JSON reference resolving
ajv compile ##Does meta-schema validation, using exit code
-o [FILE] ##Creates file like STANDALONE
##Def FILE: stdout
ajv [validate] ##Does data validation, using exit code and output
-d FILE ##Data file
--errors=FORMAT ##How to report errors, among:
## - js (def): JavaScript
## - json: beautified JSON
## - line: non-beaufied JSON
## - text: using AJV.errorText()
## - no
--changes=FORMAT ##Same FORMAT as --errors
##Logs modifications (e.g. from AOPTS.removeAdditional|useDefaults|coerceTypes) as JSON patches (RFC 6902)
ajv test ##Same as ajv validate, but must specify if output is supposed to be --[in]valid
-d FILE ##
--[in]valid ##
--errors=FORMAT ##Like ajv validate
ajv migrate ##Migrate a meta-schema using JSON schema v4 to the version specified by --spec instead
-o FILE ##Output to a FILE instead of modifying input file
--indent=NUM ##
--validate-schema=false ##
/=+===============================+=\
/ : : \
)==: ERRORS :==(
\ :_______________________________: /
\=+===============================+=/
VALIDATE.errors #Of the last VALIDATE()
#ERROR_OBJ_ARR:
# - null if no errors
# - only the first error, unless AOPTS.allErrors true
# - can still be an ARR of errors due to keywords like anyOf|if|...
AJV.errorsText(ERR_OBJ_ARR[,OPTS])#Returns "data.DATA_PATH MESSAGE,...", e.g. "data/examplevar should be >= 10"
->STR #OPTS: separator (def: ","), dataVar (def: "data")
#Can be used as human-friendly error message
ERROR_OBJ.message #'ERROR': if AOPTS.messages true (def)
#Does not include paths, e.g. only 'should be >= 10'
##Can be translated into LANG by AJV-I18N.LANG(ERROR_OBJ_ARR):
## - sets ERROR_OBJ.message
## - AOPTS.messages should be false, since ERROR_OBJ.message overriddesince ERROR_OBJ.message
## - version 4.2.0
ERROR_OBJ.keyword #'KEYWORD'
ERROR_OBJ.instancePath #DATA_PATH, as JSON_POINTER (e.g. '/VAR/...')
#For rules that are one level upper than the object validated
#(e.g. required, additionalProperties, dependencies), is the object validated.
ERROR_OBJ.schemaPath #SCHEMA_PATH, as JSON_POINTER (e.g. '#/VAR/...')
ERROR_OBJ.params #Schema information. OBJ:
# (type)
# - type 'TYPE[,...]'
# (format)
# - format 'FORMAT'
# (enum)
# - allowedValues VAL_ARR
# (const)
# - allowedValue VAL
# (multipleOf)
# - multipleOf
# ([format][exclusive]maximum|minimum)
# - limit NUM, exclusive BOOL, comparison '<|<=|>|>='
# (max|minLength)
# - limit NUM
# (pattern)
# - pattern
# (items|contains)
# nothing
# (additionalItems)
# - limit NUM
# (maxItems|minItems)
# - limit NUM
# (uniqueItems)
# - i|j NUM
# (max|minProperties)
# - limit NUM
# (required)
# - missingProperty '.VAR'
# (additionalProperties)
# - additionalProperty 'VAR'
# (patternProperties)
# nothing
# (patternRequired)
# - missingPattern STR
# (propertyNames)
# - propertyName 'VAR'
# - also set as ERROR_OBJ.propertyName
# (dependencies)
# - property 'VAR', missingProperty 'VAR', deps 'STR,...', depsCount NUM
# ($ref)
# - ref STR
# (not|allOf|anyOf|if|then|else)
# nothing
# (oneOf)
# - passingSchemas null|NUM_ARR (index of schemas that succeeds if any does)
# (switch)
# - caseIndex NUM
# (custom keyword with no custom error, all ajv-keywords except format*, patternRequired and
# switch)
# - keyword 'KEYWORD'
(if AOPTS.verbose true)
ERROR_OBJ.schema #SCHEMA_VAL
ERROR_OBJ.parentSchema #PARENT_SCHEMA
ERROR_OBJ.data #DATA_VAL
AJV-ERRORS(AJV[, OPTS]) ##Version 3.0.0
##Requires AOPTS.allErrors true
SCHEMA.errorMessage[.KEYWORD] STR##If SCHEMA fails, change ERROR_OBJ to:
## - message STR
## - keyword 'errorMessage'
## - schema*: targets SCHEMA.errorMessage
## - instancePath: same
## - params.errors: original ERROR_OBJ_ARR
##Can filter by KEYWORD
## - can be VARR for required|dependencies|properties|items|etc.
## - can be _ for default match
##STR can contain "${[RELATIVE_]JSON_POINTER}" which will take DATA_VAL as input and will be
##JSON.stringified.
##OPTS:
## - keepErrors BOOL (def: false): keep original errors in ERROR_OBJ_ARR
## ERROR_OBJ.emUsed will be set to true
## - singleError BOOL (def: false) or STR: concatenate errors for each KEYWORD
AOPTS.logger OBJ|false #How console warn|error messages are printed when compilation fails.
#By default, uses global.console
#OBJ: log|warn|error(STR,...)
AOPTS.$comment BOOL|FUNC #Logs $comment JSON schema keywords
#Def: false
#FUNC is FUNC(DATA_VAL, DATA_PATH, SCHEMA)
/=+===============================+=\
/ : : \
)==: META-SCHEMA :==(
\ :_______________________________: /
\=+===============================+=/
JSON SCHEMA VERSION ==> #Default meta-schema:
# - v4: import('ajv-draft-04')
# - v6: backward compatible with v7, i.e. supported by default
# - v7: default
# - v8: import('ajv/dist/2019.js')
# - v9: import('ajv/dist/2020.js')
#If some SCHEMA.$schema differ from current one:
# - must use AJV.addMetaSchema(import('ajv/dist/refs/json-schema-VERSION.json')) with VERSION:
# - draft-06
# - draft-07
# - 2019-09/schema
# - 2020-12/schema
# - not possible with v9 because not backward compatible
OPEN API SCHEMA ==> #Supports OpenAPI 3:
# - new SCHEMA.format (with ajv-formats)
# - SCHEMA.nullable
# - SCHEMA.discriminator (if AOPTS.discriminator true, def: false)
/=+===============================+=\
/ : : \
)==: JTD :==(
\ :_______________________________: /
\=+===============================+=/
JTD ==> #Supports all
SCHEMA.metadata.* #Can use:
# - any JSON schema keyword (providing name does not exist in JTD too)
# - any custom keyword
# - "union" SCHEMA_ARR: like SCHEMA.allOf with JSON schema
#Discouraged as less portable|standard
import('ajv/dist/jtd.js') #Must be used
AJV.compileSerializer(SCHEMA)
->FUNC(OBJ)->'JSON' #Like JSON.serialize() but faster. Does not validate
AJV.compileParser(SCHEMA) #Like JSON.parse() but also validates.
->FUNC('JSON')->OBJ|undefined #Same speed as JSON.parse() when valid, faster when invalid (because stops parsing right away).
#If validation error:
# - return undefined
# - FUNC has members:
# - message 'ERROR'
# - position NUM
AOPTS.int32range #If true (def), checks for min|max with SCHEMA.type '[u]int32'
AOPTS.timestamp #STR. Whether SCHEMA.type 'timestamp' should allow DATE ('date') or 'DATE' ('string')
#Def: both
AOPTS.parseDate #BOOL. Whether SCHEMA.type 'timestamp' should be parsed by compileParser() as DATE (true) or 'DATE' (false, def)
AOPTS.allowDate #BOOL. Same as parseDate but for validation
/=+===============================+=\
/ : : \
)==: VALIDATION OPTIONS :==(
\ :_______________________________: /
\=+===============================+=/
AOPTS.strict #BOOL|'log'. Sets all of AOPTS.strict*
AOPTS.strictSchema #BOOL|'log' (def: true). Validates against schema mistakes:
# - unknown keyword
# - unknown format
# - keyword needs another one that is missing: if <-> then|else, items -> additionalItems,
# contains -> min|maxContains
AOPTS.allowMatchingProperties #BOOL|'log' (def: false). With AOPTS.strictSchema true, allow SCHEMA.patternProperties.PROP
#even if SCHEMA.properties.PROP exists
AOPTS.strictTypes #BOOL|'log' (def: 'log'). Require SCHEMA.type 'object' when SCHEMA.properties|required
#Also validates against SCHEMA.anyOf[*].type contradicting SCHEMA.type
AOPTS.allowUnionTypes #BOOL|'log' (def: false). With AOPTS.strictTypes true, validates against SCHEMA.type ARR (prefer anyOf|nullable)
# - instead of nullable, SCHEMA.type ARR with 'null' can be used too
AOPTS.strictTuples #BOOL|'log' (def: 'log'). Validates against SCHEMA.items ARR without SCHEMA.min|max|additionalItems
AOPTS.strictRequired #BOOL|'log' (def: false). Validates against SCHEMA.required without SCHEMA.properties.PROP
AOPTS.strictNumbers #BOOL (def: true): does not allow NaN|Infinity as number
AOPTS.validateFormats #If unknown format, throws exception: true (def) or false (as per spec)
#Requires AOPTS.strict true
AOPTS.multipleOfPrecision #Max NUM of decimals for multipleOf KEYWORD argument
AOPTS.unicodeRegExp #BOOL (def: true): use "u" flag with SCHEMA.pattern[Properties]
AOPTS.loopRequired|Enum #If SCHEMA.required|enum ARR length is above NUM (def: 200), implement it as a loop under-the-hood (performance optimization)
AOPTS.ownProperties #BOOL (def: false): ignore inherited properties
/=+===============================+=\
/ : : \
)==: JSON REFERENCES :==(
\ :_______________________________: /
\=+===============================+=/
WHERE ==> #All this is for JSON references in schemas, not in data.
JSON POINTERS ==> #Against the spec: trailing slash is ignored
#Relative JSON pointers are only possible when using { $data }
AJV.compileAsync(SCHEMA[, BOOL]) #Same as AJV.compile() but async, waiting for remote JSON references to be resolved.
->PROMISE_VALIDATE #Is required when using remote JSON references (i.e. with URI, not just #HASH)
#Possible ERRORs: loadSchema() ERROR, invalid schema
#BOOL must be true for meta-schemas
AOPTS.loadSchema('URI') #Function to fetch remote JSON references
->PROMISE_SCHEMA #Required when using compileAsync()
AOPTS.inlineRefs #Whether to inline JSON references:
# - true (def): always
# - false: never
# - NUM: only if <= NUM keywords
AOPTS.uriResolver #Customize the module used for URI resolution
/=+===============================+=\
/ : : \
)==: MODIFICATION :==(
\ :_______________________________: /
\=+===============================+=/
MODIFICATION ==> #The following directly modify data OBJ
AOPTS.removeAdditional #Remove extra properties (e.g. the ones specified by SCHEMA.additionalProperties)
#Can be:
# - false (def)
# - "all": whatever SCHEMA.additionalProperties is
# - true: only if SCHEMA.additionalProperties false
# - "failing": only if SCHEMA.additionalProperties false,
# or if SCHEMA.additionalProperties and properties do not validate to it
AOPTS.useDefaults #Apply SCHEMA.default. Can be:
# - false (def)
# - true: by deep copy, for undefined
# - "empty": by deep copy, for undefined|null|""
#Must be inside properties|items
#Cannot be used inside switch|if|anyOf|oneOf|not or macro keywords
AOPTS.coerceTypes #Try to transtype to SCHEMA.type. Can be:
# - false (def)
# - true: only for scalar types
# - "array": for array type too, i.e. VAL <-> [VAL]
#Some difference from JavaScript:
# - String(null) -> ""
# - Boolean("true|false"|1|0|null|[BOOL])->true|false, others errors
# - null(""|0|false|[null]) -> null, others errors
/=+===============================+=\
/ : : \
)==: EXTENSIONS :==(
\ :_______________________________: /
\=+===============================+=/
AJV-FORMATS(AJV[, ARR|FOPTS]) ##No formats are included by default: ajv-formats must be used
##Also adds formats from OpenAPI: "byte|int32|int64|float|double|password|binary"
##Version 3.0.1
##ARR: same as FOPTS.formats ARR
FOPTS.formats ##'FORMAT'_ARR to pick
FOPTS.keywords ##If true (def), add support for SCHEMA.format[Excusive]Maximum|Minimum
FOPTS.mode ##Either "full" (slower) or "fast" (less accurate)
AJV-FORMATS-DRAFT-2019(AJV) ##Needed for formats iri[-reference] and idn-email|hostname
##Version 1.6.1
import('ajv-formats-draft2019
/formats[/FORMAT.js]') ##FUNC, to used with AOPTS.formats.FORMAT
AJV.addFormat('FORMAT', VAL)->AJV #Add custom SCHEMA.format according to VAL:
AOPTS.formats.FORMAT VAL # - OBJ:
# - type 'string' (def) or 'number'
# - validate 'REGEXP'|REGEXP|true|FUNC(STR|NUM)->[PROMISE_]BOOL
# - async BOOL (def: false): must be true if validate returns PROMISE
# - compare(STR, STR2)->-1|0|1: to make SCHEMA.format[Exlusive]Maximum|Minimum work
# - VAL2: shortcut for OBJ.validate VAL2
AJV.addKeyword(KOPTS)->AJV #Add custom SCHEMA.KEYWORD
AOPTS.keywords KOPTS_ARR #Can be performed in four different ways according to KOPTS:
# - validate(SCHEMA_VAL, DATA_VAL, PARENT_SCHEMA, DATA_CONTEXT)->[PROMISE_]BOOL
# - fired during VALIDATE()
# - is the most flexible, but slowest
# - compile(SCHEMA_VAL, PARENT_SCHEMA, COMPILE_CONTEXT)->VALIDATE(DATA_VAL)->[PROMISE_]BOOL
# - first function is fired during AJV.compile(), second during VALIDATE()
# - macro(SCHEMA_VAL, PARENT_SCHEMA, COMPILE_CONTEXT)->EXTRA_SCHEMA
# - fired during AJV.compile()
# - can be the most efficient
# - code(CODE_CONTEXT)
# - fired during AJV.compile()
# - the fastest, but more complicated to use
#DATA_CONTEXT:
# - instancePath DATA_PATH
# - parentData OBJ|ARR
# - parentDataProperty 'VAR'|INDEX
# - rootData OBJ|ARR
# - dynamicAnchors.'#HASH' VALIDATE
#CODE_CONTEXT:
# - keyword 'KYWORD'
# - schema SCHEMA_VAL
# - data CODE
# - parentSchema PARENT_SCHEMA
# - fail|pass(CODE): fail|pass based on a BOOL condition
# - schemaType: like KOPTS.*
# - allErrors: like AOPTS.*
# - many more properties not documented yet
#COMPILE_CONTEXT:
# - parentData|parentDataProperty: like DATA_CONTEXT
# - dataLevel NUM: depth level of DATA_VAL
# - schema SCHEMA
# - schemaPath SCHEMA_PATH
# - self AJV
# - opts AOPTS
# - baseId: base URI for $ref resolving
# - compositeRule BOOL: is inside anyOf|oneOf|not|if|switch
# - many more properties not documented yet
#KOPTS:
# - keyword 'KEYWORD'[_ARR]
# - must be [:alnum:]-_$ and should be namespaced
# - type 'TYPE'[_ARR] (def: all): only trigger on those types
# - schemaType 'TYPE'[_ARR]: type of the keyword arguments
# - dependencies 'VAR'_ARR: require PARENT_SCHEMA.VAR
# - metaSchema SCHEMA (def: current meta-schemas)
# - implements 'KEYWORD'_ARR
# (validate|code() only)
# - $data BOOL (def: false): allow using $data (see JSON schemas doc)
# - $dataError OBJ: same as KOPTS.error but for $data
# (validate|compile() only)
# - valid BOOL (def: false): FUNC is performed but its result can be ignored, i.e. only used for side-effects
# - modifying BOOL (def: false): allow FUNC to modify object (through PARENT|ROOT_DATA)
# - schema BOOL (def: true): pass SCHEMA_VAL|PARENT_SCHEMA as arguments
# - async BOOL (def: false):
# - if returning validate() returns PROMISE_BOOL
# - RSCHEMA.$async true should be true as well
#AOPTS:
# - passContext BOOL: if false (def), keep `this` from VALIDATE with validate()
AJV.getKeyword('KEYWORD')->VAL #Returns KOPTS, true (if builtin) or false (unknown)
AJV.removeKeyword('KEYWORD')->AJV #
KOPTS.error #Sets ERROR_OBJ.*
#OBJ:
# - message 'MESSAGE'|FUNC(COMPILE_CONTEXT)->CODE
# - params FUNC(COMPILE_CONTEXT)->CODE
#Otherwise, will use default:
# - keyword 'RULE'
# - message 'should pass "RULE" keyword validation'
# - params: keyword 'RULE'
KOPTS.validate.errors #Alternative for KOPTS.error, with only validate|compile() custom keywords
#Like VALIDATE.errors
#Must define ERROR_OBJ.message|keyword|params
# - other ERROR_OBJ.* are filled in by AJV
#If KOPTS.async true, should reject new AJV.ValidationErrors(ERROR_OBJ_ARR) instead.
KOPTS.errors #BOOL|'full'
#Whether KOPTS.validate.errors is set
AJV.str`STR` #CODE
#Like STR, but adds some escaping for security.
#Can include other CODE inside ${...}
AJV._`CODE` #CODE
#Same for 'CODE'
/=+===============================+=\
/ : : \
)==: AJV-KEYWORDS :==(
\ :_______________________________: /
\=+===============================+=/
AJVKEYWORDS ##Add some custom rules (documented in JSON schema doc)
(AJV[, 'KEYWORD'[_ARR]]) ##Version 5.1.0
require
('ajv-keywords/keywords/KEYWORD')
(AJV[, KKOPTS]) ##Same
require
('ajv-keywords/dist/definitions
[/KEYWORD]')
(AJV[, KKOPTS]) ##KOPTS, to use with AOPTS.keywords
KKOPTS.defaultMeta ##Meta-schema 'URI' for SCHEMA.select|deepProperties
##Def: 'http://json-schema.org/schema'
AJV-MERGE-PATCH ##Adds SCHEMA.$merge|$patch
##Version 5.0.1
AJV-MERGE-PATCH(AJV) ##