Interface ObjectSchema

Hierarchy

Index

Methods

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

  • values: Array<any>

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

  • peers: Array<string>

Returns

ObjectSchema

public assert(ref: string, schema: Schema, message: string): ObjectSchema

Verifies an assertion where.

Parameters

  • ref: string
  • schema: Schema
  • message: string

Returns

ObjectSchema

public assert(ref: Reference, schema: Schema, message: 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

  • value: any

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

  • desc: string

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

  • value: any

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

  • values: Array<any>

Returns

T in 'joi'.AnySchema<T extends AnySchema<Schema>>

public keys(schema?: SchemaMap): ObjectSchema

Sets the allowed object keys.

Parameters

Returns

ObjectSchema

public length(limit: number): ObjectSchema

Specifies the exact number of keys in the object.

Parameters

  • limit: number

Returns

ObjectSchema

public max(limit: number): ObjectSchema

Specifies the maximum number of keys in the object.

Parameters

  • limit: number

Returns

ObjectSchema

public meta(meta: Object): T in 'joi'.AnySchema<T extends AnySchema<Schema>>

Attaches metadata to the key.

Parameters

  • meta: Object

Returns

T in 'joi'.AnySchema<T extends AnySchema<Schema>>

public min(limit: number): ObjectSchema

Specifies the minimum number of keys in the object.

Parameters

  • limit: number

Returns

ObjectSchema

public notes(notes: string): T in 'joi'.AnySchema<T extends AnySchema<Schema>>

Annotates the key

Parameters

  • notes: string

Returns

T in 'joi'.AnySchema<T extends AnySchema<Schema>>

public notes(notes: Array<string>): T in 'joi'.AnySchema<T extends AnySchema<Schema>>

Parameters

  • notes: Array<string>

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

  • peers: Array<string>

Returns

ObjectSchema

public pattern(regex: RegExp, schema: Schema): ObjectSchema

Specify validation rules for unknown keys matching a pattern.

Parameters

  • regex: RegExp
  • schema: Schema

Returns

ObjectSchema

public rename(from: string, to: string, options?: RenameOptions): ObjectSchema

Renames a key to another name (deletes the renamed key).

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

  • notes: string

Returns

T in 'joi'.AnySchema<T extends AnySchema<Schema>>

public tags(notes: Array<string>): T in 'joi'.AnySchema<T extends AnySchema<Schema>>

Parameters

  • notes: Array<string>

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

  • name: string

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

  • allow?: boolean optional

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

  • values: Array<any>

Returns

T in 'joi'.AnySchema<T extends AnySchema<Schema>>

public when(ref: string, options: WhenOptions): AlternativesSchema

Converts the type into an alternatives type where the conditions are merged into the type definition where:

Parameters

Returns

AlternativesSchema

public when(ref: Reference, options: WhenOptions): 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

  • peers: Array<string>

Returns

ObjectSchema