-
mode
—'default'
by default invalidator()
,'strong'
by default inparser()
.
See also strong mode documentation.'lax'
mode disables some default schema coherence checks.'spec'
mode is the same as'lax'
but also disables format assertion indraft2019-09
and newer$schema
versions. -
useDefaults
—false
by default. Applydefault:
values from the schema to missing properties. -
removeAdditional
—false
by default.
Removes additional properties instead of failing the validation on them.
SupportsadditionalProperties: false
andadditionalItems: false
.
Note that it fails to compile the schema in case of uncertain paths with this option. -
includeErrors
—false
by default.
Enable returning errors (without it, just a validaton flag is returned). -
allErrors
—false
by default.
Return all errors, not just the first one. -
contentValidation
—false
by default fordraft/2019-09
and newer,
true
by default fordraft7
and older.
EnablescontentEncoding
,contentMediaType
,contentSchema
usage for validation and makes
failing those checks affect the boolean result of the validation.
By default they are no-op per spec sincedraft/2019-09
, and hence are treated as an unused
keyword and raise an error at compile time unlessallowUnusedKeywords
option is enabled. -
dryRun
—false
by default.
Don't produce a validator, just verify the schema and throw on first error. -
lint
—false
by default.
Don't produce a validator, just verify the schema and collect all errors. Same as Linter mode. -
$schemaDefault
—null
by default.
Can not be used ifrequireSchema
is on. -
formatAssertion
—true
by default (false
by default whenmode = 'spec'
and$schema
isdraft2019-09
or later).Switching it to
false
will disableformat
assertions, essentially making them not affect the result of validation at all, i.e. validation would pass regardless of allformat
strings in the schema.That (
false
) behaviour is specified as default in the upstream sincedraft2019-09
, but not followed here, unlessmode
is set to'spec'
, due to being potentially dangereous/unsafe and missing expected validation.For more info, see upstream documentation and upstream changelog.
-
formats
—{}
by default.
Additional formats to use. -
weakFormats
—true
in'default'
and'lax'
/'spec'
modes,false
in'strong'
mode by default.
Add support for formats deemed potentially weak (currently, onlyRegExp
). -
extraFormats
—false
by default.
Enable extra built-in non-standard formats, see formats.js. -
schemas
— empty by default.
Either aMap
, anArray
, or anObject
with schemas to resolve external$ref
pointers.
All these options are false
by default in 'default'
and 'lax
/'spec'
modes and true
by
default in 'strong'
mode.
-
requireSchema
— refuse to use schemas with missing$schema
. -
requireValidation
— refuse to use schemas which do not perform validation of all items or properties. -
requireStringValidation
— refuse to use schemas which do not perform validation of all string properties against aformat
,pattern
, or acontentSchema
. -
complexityChecks
— refuse to use schemas that might be missing required checks to avoid potential DoS, e.g. requiremaxLength
on complex regexps andmaxItems
on complexuniqueItems
. Note that it will pass if those are present but have a very high value, the only intent is to prevent a mistake when those checks are missed. If they are present, it is assumed that the shema author chose an appropriate value corresponding to the regex complexity. -
forbidNoopValues
— refuse to compile schemas with certain noop keywords that make no sense.
Currently, that is only$recursiveAnchor: false
.
This option is overridable even in'strong'
mode.
-
allowUnusedKeywords
—opts.mode === 'lax' || opts.mode === 'spec'
by default.
Allows unused keywords to be present in the schema. -
allowUnreachable
—opts.mode === 'lax' || opts.mode === 'spec'
by default.
Allows unreachable checks to be present in the schema.
If certain assumptions about input are always true, that information can be used to optimize the generated validator.
-
unmodifiedPrototypes
—false
by default. Assume no mangledObject
/Array
prototypes in runtime. -
isJSON
—false
by default. Assume input to be JSON, which e.g. makesundefined
impossible.