Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Root

Index

Properties

ValidationError

0.0.46 provide
ValidationError: new (message: string, details: any, original: any) => ValidationError

Type declaration

cache

0.0.46 provide

override

0.0.46 provide
override: symbol

A special value used with any.allow(), any.invalid(), and any.valid() as the first value to reset any previously set values.

version

0.0.46 provide
version: string

Current version of the joi package.

Methods

allow

0.0.46 provide
  • allow(...values: any[]): Schema<any>
  • Whitelists a value

    Parameters

    • Rest ...values: any[]

    Returns Schema<any>

alt

0.0.46 provide

alternatives

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

    Parameters

    Returns AlternativesSchema

  • Parameters

    Returns AlternativesSchema

any

0.0.46 provide
  • Generates a schema object that matches any data type.

    Returns AnySchema

array

0.0.46 provide
  • Generates a schema object that matches an array data type.

    Returns ArraySchema

assert

0.0.46 provide
  • Validates a value against a schema and throws if validation fails.

    Parameters

    Returns void

  • Parameters

    Returns void

attempt

0.0.46 provide
  • Validates a value against a schema, returns valid object, and throws if validation fails.

    Parameters

    Returns any

  • Parameters

    Returns any

binary

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

    Returns BinarySchema

bool

0.0.46 provide
  • 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

0.0.46 provide
  • 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

build

0.0.46 provide
  • build(...args: any[]): any
  • Unsure, maybe alias for compile?

    Parameters

    • Rest ...args: any[]

    Returns any

checkPreferences

0.0.46 provide
  • Checks if the provided preferences are valid.

    Throws an exception if the prefs object is invalid.

    The method is provided to perform inputs validation for the any.validate() and any.validateAsync() methods. Validation is not performed automatically for performance reasons. Instead, manually validate the preferences passed once and reuse.

    Parameters

    Returns void

compile

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

    Parameters

    Returns Schema<any>

custom

0.0.46 provide
  • Creates a custom validation schema.

    Parameters

    Returns Schema<any>

date

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

    Returns DateSchema

defaults

0.0.46 provide
  • Creates a new Joi instance that will apply defaults onto newly created schemas through the use of the fn function that takes exactly one argument, the schema being created.

    Parameters

    • fn: SchemaFunction

      The function must always return a schema, even if untransformed.

    Returns Root

disallow

0.0.46 provide
  • disallow(...values: any[]): Schema<any>
  • Parameters

    • Rest ...values: any[]

    Returns Schema<any>

equal

0.0.46 provide
  • equal(...values: any[]): Schema<any>
  • Parameters

    • Rest ...values: any[]

    Returns Schema<any>

exist

0.0.46 provide
  • Alias of required.

    Returns Schema<any>

expression

0.0.46 provide
  • Generates a dynamic expression using a template string.

    Parameters

    Returns any

extend

0.0.46 provide
  • Creates a new Joi instance customized with the extension(s) you provide included.

    Parameters

    Returns any

forbidden

0.0.46 provide
  • Marks a key as forbidden which will not allow any value except undefined. Used to explicitly forbid keys.

    Returns Schema<any>

func

0.0.46 provide
  • Generates a schema object that matches a function type.

    Returns FunctionSchema

function

0.0.46 provide
  • Generates a schema object that matches a function type.

    Returns FunctionSchema

in

0.0.46 provide
  • Creates a reference that when resolved, is used as an array of values to match against the rule.

    Parameters

    Returns Reference

invalid

0.0.46 provide
  • invalid(...values: any[]): Schema<any>
  • Blacklists a value

    Parameters

    • Rest ...values: any[]

    Returns Schema<any>

isError

0.0.46 provide
  • Checks whether or not the provided argument is an instance of ValidationError

    Parameters

    • error: any

    Returns error is ValidationError

isExpression

0.0.46 provide
  • isExpression(expression: any): boolean
  • Checks whether or not the provided argument is an expression.

    Parameters

    • expression: any

    Returns boolean

isRef

0.0.46 provide
  • Checks whether or not the provided argument is a reference. It's especially useful if you want to post-process error messages.

    Parameters

    • ref: any

    Returns ref is Reference

isSchema

0.0.46 provide
  • Checks whether or not the provided argument is a joi schema.

    Parameters

    Returns schema is AnySchema

link

0.0.46 provide
  • Links to another schema node and reuses it for validation, typically for creative recursive schemas.

    Parameters

    • Optional ref: string

      the reference to the linked schema node. Cannot reference itself or its children as well as other links. Links can be expressed in relative terms like value references (Joi.link('...')), in absolute terms from the schema run-time root (Joi.link('/a')), or using schema ids implicitly using object keys or explicitly using any.id() (Joi.link('#a.b.c')).

    Returns LinkSchema

not

0.0.46 provide
  • not(...values: any[]): Schema<any>
  • Parameters

    • Rest ...values: any[]

    Returns Schema<any>

number

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

    Returns NumberSchema

object

0.0.46 provide
  • Generates a schema object that matches an object data type (as well as JSON strings that have been parsed into objects).

    Type parameters

    • TSchema = any

    • isStrict = false

    • T = TSchema

    Parameters

    Returns ObjectSchema<TSchema>

optional

0.0.46 provide
  • 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 Schema<any>

options

0.0.46 provide
  • options(...args: any[]): any
  • Unsure, maybe alias for preferences?

    Parameters

    • Rest ...args: any[]

    Returns any

preferences

0.0.46 provide
  • Overrides the global validate() options for the current key and any sub-key.

    Parameters

    Returns Schema<any>

prefs

0.0.46 provide
  • Overrides the global validate() options for the current key and any sub-key.

    Parameters

    Returns Schema<any>

ref

0.0.46 provide
  • Generates a reference to the value of the named key.

    Parameters

    Returns Reference

required

0.0.46 provide
  • Marks a key as required which will not allow undefined as value. All keys are optional by default.

    Returns Schema<any>

string

0.0.46 provide
  • 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

symbol

0.0.46 provide
  • Generates a schema object that matches any symbol.

    Returns SymbolSchema

trace

0.0.46 provide
  • trace(...args: any[]): any
  • Unsure, maybe leaked from @hapi/lab/coverage/initialize

    Parameters

    • Rest ...args: any[]

    Returns any

types

0.0.46 provide

untrace

0.0.46 provide
  • untrace(...args: any[]): any
  • Parameters

    • Rest ...args: any[]

    Returns any

valid

0.0.46 provide
  • valid(...values: any[]): Schema<any>
  • Adds the provided values into the allowed whitelist and marks them as the only valid values allowed.

    Parameters

    • Rest ...values: any[]

    Returns Schema<any>

when

0.0.46 provide

x

0.0.46 provide
  • Generates a dynamic expression using a template string.

    Parameters

    Returns any