Methods
public allow(value: any, values?: Array<any>): T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Whitelists a value
Parameters
-
value: any
-
values?: Array<any> optional
Returns
T in 'joi'.AnySchema<T extends AnySchema<Schema>>
public allow(values: Array<any>): T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Parameters
Returns
T in 'joi'.AnySchema<T extends AnySchema<Schema>>
public and(peer1: string, peer2: string, peers?: Array<string>): ObjectSchema
Defines an all-or-nothing relationship between keys where if one of the peers is present, all of them are required as well.
Parameters
-
peer1: string
-
peer2: string
-
peers?: Array<string> optional
Returns
ObjectSchema
public and(peers: Array<string>): ObjectSchema
Parameters
Returns
ObjectSchema
public concat(schema: T in 'joi'.AnySchema<T extends AnySchema<Schema>>): T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Returns a new type that is the result of adding the rules of one type to another.
Parameters
-
schema: T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Returns
T in 'joi'.AnySchema<T extends AnySchema<Schema>>
public default(value: any): T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Sets a default value if the original value is undefined.
Parameters
Returns
T in 'joi'.AnySchema<T extends AnySchema<Schema>>
public description(desc: string): T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Annotates the key
Parameters
Returns
T in 'joi'.AnySchema<T extends AnySchema<Schema>>
public example(value: any): T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Annotates the key with an example value, must be valid.
Parameters
Returns
T in 'joi'.AnySchema<T extends AnySchema<Schema>>
public forbidden(): T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Marks a key as forbidden which will not allow any value except undefined. Used to explicitly forbid keys.
Returns
T in 'joi'.AnySchema<T extends AnySchema<Schema>>
public invalid(value: any, values?: Array<any>): T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Blacklists a value
Parameters
-
value: any
-
values?: Array<any> optional
Returns
T in 'joi'.AnySchema<T extends AnySchema<Schema>>
public invalid(values: Array<any>): T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Parameters
Returns
T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Sets the allowed object keys.
Parameters
Returns
ObjectSchema
public length(limit: number): ObjectSchema
Specifies the exact number of keys in the object.
Parameters
Returns
ObjectSchema
public max(limit: number): ObjectSchema
Specifies the maximum number of keys in the object.
Parameters
Returns
ObjectSchema
public meta(meta: Object): T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Attaches metadata to the key.
Parameters
Returns
T in 'joi'.AnySchema<T extends AnySchema<Schema>>
public min(limit: number): ObjectSchema
Specifies the minimum number of keys in the object.
Parameters
Returns
ObjectSchema
public notes(notes: string): T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Annotates the key
Parameters
Returns
T in 'joi'.AnySchema<T extends AnySchema<Schema>>
public notes(notes: Array<string>): T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Parameters
Returns
T in 'joi'.AnySchema<T extends AnySchema<Schema>>
public optional(): T in 'joi'.AnySchema<T extends AnySchema<Schema>>
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.
Returns
T in 'joi'.AnySchema<T extends AnySchema<Schema>>
public options(options: ValidationOptions): T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Overrides the global validate() options for the current key and any sub-key.
Parameters
Returns
T in 'joi'.AnySchema<T extends AnySchema<Schema>>
public or(peer1: string, peer2: string, peers?: Array<string>): ObjectSchema
Defines a relationship between keys where one of the peers is required (and more than one is allowed).
Parameters
-
peer1: string
-
peer2: string
-
peers?: Array<string> optional
Returns
ObjectSchema
public or(peers: Array<string>): ObjectSchema
Parameters
Returns
ObjectSchema
public pattern(regex: RegExp, schema: Schema): ObjectSchema
Specify validation rules for unknown keys matching a pattern.
Parameters
Returns
ObjectSchema
public required(): T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Marks a key as required which will not allow undefined as value. All keys are optional by default.
Returns
T in 'joi'.AnySchema<T extends AnySchema<Schema>>
public strict(): T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Sets the options.convert options to false which prevent type casting for the current key and any child keys.
Returns
T in 'joi'.AnySchema<T extends AnySchema<Schema>>
public tags(notes: string): T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Annotates the key
Parameters
Returns
T in 'joi'.AnySchema<T extends AnySchema<Schema>>
public tags(notes: Array<string>): T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Parameters
Returns
T in 'joi'.AnySchema<T extends AnySchema<Schema>>
public unit(name: string): T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Annotates the key with an unit name.
Parameters
Returns
T in 'joi'.AnySchema<T extends AnySchema<Schema>>
public unknown(allow?: boolean): ObjectSchema
Overrides the handling of unknown keys for the scope of the current object only (does not apply to children).
Parameters
Returns
ObjectSchema
public valid(value: any, values?: Array<any>): T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Adds the provided values into the allowed whitelist and marks them as the only valid values allowed.
Parameters
-
value: any
-
values?: Array<any> optional
Returns
T in 'joi'.AnySchema<T extends AnySchema<Schema>>
public valid(values: Array<any>): T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Parameters
Returns
T in 'joi'.AnySchema<T extends AnySchema<Schema>>
Converts the type into an alternatives type where the conditions are merged into the type definition where:
Parameters
Returns
AlternativesSchema
Parameters
Returns
AlternativesSchema
public with(key: string, peers: string): ObjectSchema
Requires the presence of other keys whenever the specified key is present.
Parameters
-
key: string
-
peers: string
Returns
ObjectSchema
public with(key: string, peers: Array<string>): ObjectSchema
Parameters
-
key: string
-
peers: Array<string>
Returns
ObjectSchema
public without(key: string, peers: string): ObjectSchema
Forbids the presence of other keys whenever the specified is present.
Parameters
-
key: string
-
peers: string
Returns
ObjectSchema
public without(key: string, peers: Array<string>): ObjectSchema
Parameters
-
key: string
-
peers: Array<string>
Returns
ObjectSchema
public xor(peer1: string, peer2: string, peers?: Array<string>): ObjectSchema
Defines an exclusive relationship between a set of keys. one of them is required but not at the same time where:
Parameters
-
peer1: string
-
peer2: string
-
peers?: Array<string> optional
Returns
ObjectSchema
public xor(peers: Array<string>): ObjectSchema
Parameters
Returns
ObjectSchema