Interface: ValidationOptions
The options of a validation, given to DTO.validate(), DTO.validateAsync(), DTO.isValid() or to a schema (prefs(), which overrides the options of the validation for that schema). Unset options take the defaults of lakutata: abortEarly, allowUnknown, stripUnknown and convert true, cache false; the schemas built by DTO are strict nonetheless (see AnySchema.strict()).
Extends
BaseValidationOptions
Properties
abortEarly?
optionalabortEarly?:boolean
when true, stops validation on the first error, otherwise returns all the errors found.
Default
trueInherited from
BaseValidationOptions.abortEarly
allowUnknown?
optionalallowUnknown?:boolean
When true, the objects may contain unknown keys; when false, they are rejected, unless stripUnknown removes them. ObjectSchema.unknown() overrides it for an object.
Default
true (lakutata)Inherited from
BaseValidationOptions.allowUnknown
artifacts?
optionalartifacts?:boolean
when true, return artifacts alongside the value.
Default
falseInherited from
BaseValidationOptions.artifacts
cache?
optionalcache?:boolean
when true, schema caching is enabled (for schemas with explicit caching rules).
Default
falseInherited from
BaseValidationOptions.cache
context?
optionalcontext?:Context
provides an external data set to be used in references
Inherited from
BaseValidationOptions.context
convert?
optionalconvert?:boolean
when true, attempts to cast values to the required types (e.g. a string to a number).
Default
trueInherited from
BaseValidationOptions.convert
dateFormat?
optionaldateFormat?:"string"|"date"|"iso"|"time"|"utc"
sets the string format used when converting dates to strings in error messages and casting.
Default
'iso'Inherited from
BaseValidationOptions.dateFormat
debug?
optionaldebug?:boolean
when true, valid results and throw errors are decorated with a debug property which includes an array of the validation steps used to generate the returned result.
Default
falseInherited from
BaseValidationOptions.debug
errors?
optionalerrors?:ErrorFormattingOptions
error formatting settings.
Inherited from
BaseValidationOptions.errors
externals?
optionalexternals?:boolean
if false, the external rules set with any.external() are ignored, which is required to ignore any external validations in synchronous mode (or an exception is thrown).
Default
trueInherited from
BaseValidationOptions.externals
messages?
optionalmessages?:LanguageMessages
Error message templates overriding the default ones, by error code ({'string.min': '…'}) or by language then error code. The variables in double braces ({{#label}}) are HTML-escaped when errors.escapeHtml is true.
Default
{}noDefaults?
optionalnoDefaults?:boolean
when true, do not apply default values.
Default
falseInherited from
BaseValidationOptions.noDefaults
nonEnumerables?
optionalnonEnumerables?:boolean
when true, inputs are shallow cloned to include non-enumerable properties.
Default
falseInherited from
BaseValidationOptions.nonEnumerables
presence?
optionalpresence?:PresenceMode
sets the default presence requirements. Supported modes: 'optional', 'required', and 'forbidden'.
Default
'optional'Inherited from
BaseValidationOptions.presence
skipFunctions?
optionalskipFunctions?:boolean
when true, ignores unknown keys with a function value.
Default
falseInherited from
BaseValidationOptions.skipFunctions
stripUnknown?
optionalstripUnknown?:boolean| {arrays?:boolean;objects?:boolean; }
Remove the unknown elements instead of rejecting them: true (or {objects: true}) removes the unknown keys of the objects, {arrays: true} the array items matching none of the item schemas. The keys an object allows with unknown() are kept.
Default
true (lakutata)Inherited from
BaseValidationOptions.stripUnknown
targetName?
optionaltargetName?:string|symbol
The name of the validated value in the error messages and paths: the value is validated as the key of that name of an object.