Dynamic module joi

Index

Interfaces

Functions

Functions

alternatives(types: Schema[]): Schema

Generates a type that will match one of the provided alternative schemas

Parameters

Returns

Schema

alternatives(type1: Schema, type2: Schema, types?: Schema[]): Schema

Parameters

Returns

Schema

any(): Schema

Generates a schema object that matches any data type.

Returns

Schema

array(): ArraySchema

Generates a schema object that matches an array data type.

Returns

ArraySchema

assert(value: any, schema: Schema)

Validates a value against a schema and throws if validation fails.

Parameters

binary(): BinarySchema

Generates a schema object that matches a Buffer data type (as well as the strings which will be converted to Buffers).

Returns

BinarySchema

bool(): BooleanSchema

Generates a schema object that matches a boolean data type (as well as the strings 'true', 'false', 'yes', and 'no'). Can also be called via bool().

Returns

BooleanSchema

boolean(): BooleanSchema

Returns

BooleanSchema

compile(schema: Object): Schema

Converts literal schema definition to joi schema object (or returns the same back if already a joi schema object).

Parameters

  • schema: Object

Returns

Schema

date(): DateSchema

Generates a schema object that matches a date type (as well as a JavaScript date string or number of milliseconds).

Returns

DateSchema

func(): FunctionSchema

Generates a schema object that matches a function type.

Returns

FunctionSchema

number(): NumberSchema

Generates a schema object that matches a number data type (as well as strings that can be converted to numbers).

Returns

NumberSchema

object(schema?: SchemaMap): ObjectSchema

Generates a schema object that matches an object data type (as well as JSON strings that parsed into objects).

Parameters

Returns

ObjectSchema

ref(key: string, options?: ReferenceOptions): Reference

Generates a reference to the value of the named key.

Parameters

Returns

Reference

string(): StringSchema

Generates a schema object that matches a string data type. Note that empty strings are not allowed by default and must be enabled with allow('').

Returns

StringSchema

validate(value: T, schema: Schema, options?: ValidationOptions, callback?: (err: 'joi'.ValidationError, value: T) => void)

Validates a value using the given schema and options.

Parameters

  • value: T
  • schema: Schema
  • options?: ValidationOptions optional
  • callback?: (err: 'joi'.ValidationError, value: T) => void optional

validate(value: T, schema: Object, options?: ValidationOptions, callback?: (err: 'joi'.ValidationError, value: T) => void)

Parameters

  • value: T
  • schema: Object
  • options?: ValidationOptions optional
  • callback?: (err: 'joi'.ValidationError, value: T) => void optional

validate(value: T, schema: Schema, callback: (err: 'joi'.ValidationError, value: T) => void)

Parameters

  • value: T
  • schema: Schema
  • callback: (err: 'joi'.ValidationError, value: T) => void

validate(value: T, schema: Object, callback: (err: 'joi'.ValidationError, value: T) => void)

Parameters

  • value: T
  • schema: Object
  • callback: (err: 'joi'.ValidationError, value: T) => void