Values to be whitelisted.
Allows specify schemas directly via Joi's schema api.
Sets a default value.
the value.
Annotates the key
Blacklists values for this property.
Values to be blacklisted.
Considers anything that matches the schema to be empty (undefined).
any object or joi schema to match. An undefined schema unsets that rule.
Adds the provided values into the allowed whitelist for property and marks them as the only valid values allowed.
The only valid values this property can accept.
Overrides the default joi error with a custom error if the rule fails where:
can be:
an instance of Error
- the override error.
a function (errors)
, taking an array of errors as argument, where it must either:
return a string
- substitutes the error message with this text
return a single object
or an Array
of it, where:
type
- optional parameter providing the type of the error (eg. number.min
).
message
- optional parameter if template
is provided, containing the text of the error.
template
- optional parameter if message
is provided, containing a template string,
using the same format as usual joi language errors.
context
- optional parameter, to provide context to your error if you are using the template
.
return an Error
- same as when you directly provide an Error
,
but you can customize the error message based on the errors.
Note that if you provide an Error
, it will be returned as-is, unmodified and undecorated with any of the
normal joi error properties. If validation fails and another error is found before the error
override, that error will be returned and the override will be ignored (unless the abortEarly
option has been set to false
).
Annotates the key with an example value, must be valid.
Allows for additional values to be considered valid booleans by converting them to false during validation. Requires the validation convert option to be true. String comparisons are by default case insensitive, see boolean.insensitive() to change this behavior.
Marks a key as forbidden which will not allow any value except undefined. Used to explicitly forbid keys.
Blacklists values for this property.
Values to be blacklisted.
Overrides the key name in error messages.
The label to use.
Attaches metadata to the key.
Blacklists values for this property.
Values to be blacklisted.
Annotates the key
Adds the provided values into the allowed whitelist for property and marks them as the only valid values allowed.
Marks a key as optional which will allow undefined as values. Used to annotate the schema for readability as all keys are optional by default.
Overrides the global validate() options for the current key and any sub-key.
Outputs the original untouched value instead of the casted value.
Marks a key as required which will not allow undefined as value. All keys are optional by default.
Allows the values provided to truthy and falsy as well as the "true" and "false" default conversion (when not in strict() mode) to be matched in a case insensitive manner.
Optional parameter defaulting to true which allows you to reset the behavior of sensitive by providing a falsy value
Sets the options.convert options to false which prevent type casting for the current key and any child keys.
Marks a key to be removed from a resulting object or array after validation. Used to sanitize output.
Annotates the key
Allows for additional values to be considered valid booleans by converting them to true during validation. Requires the validation convert option to be true. String comparisons are by default case insensitive, see boolean.insensitive() to change this behavior.
Annotates the key with an unit name.
Adds the provided values into the allowed whitelist for property and marks them as the only valid values allowed.
The only valid values this property can accept.
Generated using TypeDoc
Whitelists values. Note that this list of allowed values is in addition to any other permitted values. To create an exclusive list of values, use the
Valid
decorator.