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 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>>
public length(limit: number): ArraySchema
Specifies the exact number of items in the array.
Parameters
Returns
ArraySchema
public max(limit: number): ArraySchema
Specifies the maximum number of items in the array.
Parameters
Returns
ArraySchema
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): ArraySchema
Specifies the minimum number of items in the array.
Parameters
Returns
ArraySchema
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 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 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