Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ArraySchemaDecorator

Hierarchy

  • ArraySchemaModifiers
  • TypedPropertyDecorator<AllowedPropertyTypes>
    • ArraySchemaDecorator

Callable

  • ArraySchemaDecorator<TClass, TKey>(target: TClass, propertyKey: TKey): void
  • Type parameters

    • TClass: MapAllowUnions<TClass, TKey, AllowedPropertyTypes>

    • TKey: string | symbol

    Parameters

    • target: TClass
    • propertyKey: TKey

    Returns void

Index

Methods

allow

  • Whitelists values. Note that this list of allowed values is in addition to any other permitted values. To create an exclusive list of values, use the Valid decorator.

    Parameters

    • value: any
    • Rest ...values: any[]

      Values to be whitelisted.

    Returns ArraySchemaDecorator

custom

  • custom(schemaBuilder: (options: { joi: Root; schema: Schema }) => Schema): this
  • Allows specify schemas directly via Joi's schema api.

    Parameters

    • schemaBuilder: (options: { joi: Root; schema: Schema }) => Schema
        • (options: { joi: Root; schema: Schema }): Schema
        • Parameters

          • options: { joi: Root; schema: Schema }
            • joi: Root
            • schema: Schema

          Returns Schema

    Returns this

default

description

disallow

empty

  • Considers anything that matches the schema to be empty (undefined).

    Parameters

    • Optional schema: any

      any object or joi schema to match. An undefined schema unsets that rule.

    Returns ArraySchemaDecorator

equal

  • Adds the provided values into the allowed whitelist for property and marks them as the only valid values allowed.

    Parameters

    • value: any
    • Rest ...values: any[]

      The only valid values this property can accept.

    Returns ArraySchemaDecorator

  • Parameters

    • values: any[]

    Returns ArraySchemaDecorator

error

  • Overrides the default joi error with a custom error if the rule fails where:

    Parameters

    • err: Error | ValidationErrorFunction

      can be: an instance of Error - the override error. a function (errors), taking an array of errors as argument, where it must either: return a string - substitutes the error message with this text return a single object or an Array of it, where: type - optional parameter providing the type of the error (eg. number.min). message - optional parameter if template is provided, containing the text of the error. template - optional parameter if message is provided, containing a template string, using the same format as usual joi language errors. context - optional parameter, to provide context to your error if you are using the template. return an Error - same as when you directly provide an Error, but you can customize the error message based on the errors. Note that if you provide an Error, it will be returned as-is, unmodified and undecorated with any of the normal joi error properties. If validation fails and another error is found before the error override, that error will be returned and the override will be ignored (unless the abortEarly option has been set to false).

    Returns ArraySchemaDecorator

exactLength

example

forbidden

invalid

items

  • items(type: Schema, ...types: Schema[]): ArraySchemaDecorator
  • items(itemsSchemaBuilder: (joi: Root) => AnySchema | ArraySchema | AlternativesSchema | BinarySchema | BooleanSchema | DateSchema | FunctionSchema | NumberSchema | ObjectSchema<any> | StringSchema | LinkSchema | SymbolSchema | Schema[]): ArraySchemaDecorator
  • List the types allowed for the array values.

    Parameters

    • type: Schema
    • Rest ...types: Schema[]

    Returns ArraySchemaDecorator

  • List the types allowed for the array values.

    Parameters

    • itemsSchemaBuilder: (joi: Root) => AnySchema | ArraySchema | AlternativesSchema | BinarySchema | BooleanSchema | DateSchema | FunctionSchema | NumberSchema | ObjectSchema<any> | StringSchema | LinkSchema | SymbolSchema | Schema[]
        • (joi: Root): AnySchema | ArraySchema | AlternativesSchema | BinarySchema | BooleanSchema | DateSchema | FunctionSchema | NumberSchema | ObjectSchema<any> | StringSchema | LinkSchema | SymbolSchema | Schema[]
        • Parameters

          • joi: Root

          Returns AnySchema | ArraySchema | AlternativesSchema | BinarySchema | BooleanSchema | DateSchema | FunctionSchema | NumberSchema | ObjectSchema<any> | StringSchema | LinkSchema | SymbolSchema | Schema[]

    Returns ArraySchemaDecorator

label

max

meta

min

not

note

only

  • Adds the provided values into the allowed whitelist for property and marks them as the only valid values allowed.

    Returns ArraySchemaDecorator

optional

  • 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 ArraySchemaDecorator

options

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

    Parameters

    • options: ValidationOptions

    Returns ArraySchemaDecorator

ordered

  • List the types in sequence order for the array values..

    Parameters

    • type: Schema
    • Rest ...types: Schema[]

    Returns ArraySchemaDecorator

  • List the types in sequence order for the array values..

    Parameters

    • itemsSchemaBuilder: (joi: Root) => Schema[]
        • (joi: Root): Schema[]
        • Parameters

          • joi: Root

          Returns Schema[]

    Returns ArraySchemaDecorator

raw

required

single

  • Allow single values to be checked against rules as if it were provided as an array. enabled can be used with a falsy value to go back to the default behavior.

    Parameters

    • Optional enabled: any

    Returns ArraySchemaDecorator

sparse

  • Allow this array to be sparse. enabled can be used with a falsy value to go back to the default behavior.

    Parameters

    • Optional enabled: any

    Returns ArraySchemaDecorator

strict

  • Sets the options.convert options to false which prevent type casting for the current key and any child keys.

    Parameters

    • Optional isStrict: boolean

    Returns ArraySchemaDecorator

strip

tag

unique

unit

valid

  • Adds the provided values into the allowed whitelist for property and marks them as the only valid values allowed.

    Parameters

    • value: any
    • Rest ...values: any[]

      The only valid values this property can accept.

    Returns ArraySchemaDecorator

  • Parameters

    • values: any[]

    Returns ArraySchemaDecorator

Generated using TypeDoc