Interface StringSchema

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 alphanum(): StringSchema

Requires the string value to only contain a-z, A-Z, and 0-9.

Returns

StringSchema

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 email(): StringSchema

Requires the string value to be a valid email address.

Returns

StringSchema

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 guid(): StringSchema

Requires the string value to be a valid GUID.

Returns

StringSchema

public insensitive(): StringSchema

Allows the value to match any whitelist of blacklist item in a case insensitive comparison.

Returns

StringSchema

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 isoDate(): StringSchema

Requires the string value to be in valid ISO 8601 date format.

Returns

StringSchema

public length(limit: number): StringSchema

Specifies the exact string length required

Parameters

  • limit: number

Returns

StringSchema

public lowercase(): StringSchema

Requires the string value to be all lowercase. If the validation convert option is on (enabled by default), the string will be forced to lowercase.

Returns

StringSchema

public max(limit: number): StringSchema

Specifies the maximum number of string characters.

Parameters

  • limit: number

Returns

StringSchema

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): StringSchema

Specifies the minimum number string characters.

Parameters

  • limit: number

Returns

StringSchema

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 regex(pattern: RegExp): StringSchema

Defines a regular expression rule.

Parameters

  • pattern: RegExp

Returns

StringSchema

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 token(): StringSchema

Requires the string value to only contain a-z, A-Z, 0-9, and underscore _.

Returns

StringSchema

public trim(): StringSchema

Requires the string value to contain no whitespace before or after. If the validation convert option is on (enabled by default), the string will be trimmed.

Returns

StringSchema

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 uppercase(): StringSchema

Requires the string value to be all uppercase. If the validation convert option is on (enabled by default), the string will be forced to uppercase.

Returns

StringSchema

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