Options
All
  • Public
  • Public/Protected
  • All
Menu

The validation chain object.

Hierarchy

  • default

Index

Constructors

Properties

defaultErrorMessage: "Invalid value" = "Invalid value"

Default error message when validation fails.

hasNonStringSanitizer: boolean = false
isOptional: { options?: IOptionalOptions; value: boolean } = ...

Is this parameter optional?

Type declaration

location: ParamLocation

Location of the given parameter.

Validations and sanitations to be executed.

parameter: string[]

Parameter to be validated.

Methods

  • Remove characters that appear in the blacklist. The characters are used in a RegExp and so you will need to escape some chars, e.g. blacklist(input, '\[\]').

    Parameters

    • chars: string

      Characters to blacklist

    Returns ValidationChain.default

  • build(): Middleware<DefaultState, DefaultContext>
  • Build the validation chain. This method has to be called at the end of each validation.

    router.post(
    '/auth/login',
    body('username').equals('user').build(),
    body('password').equals('pass').build(),
    handler
    );

    Returns Middleware<DefaultState, DefaultContext>

  • getOriginalInput(ctx: RouterContext<DefaultState, DefaultContext>): unknown
  • Get original input as it is from the request body.

    Parameters

    • ctx: RouterContext<DefaultState, DefaultContext>

      The context

    Returns unknown

  • getParamFromObject(object: unknown): unknown
  • Get parameter from object.

    Parameters

    • object: unknown

      Object to look the property from

    Returns unknown

  • run(): Middleware<DefaultState, DefaultContext>
  • Remove characters with a numerical value < 32 and 127, mostly control characters. If keep_new_lines is true, newline characters are preserved (\n and \r, hex 0xA and 0xD). Unicode-safe in JavaScript.

    Parameters

    • keepNewLines: boolean = false

    Returns ValidationChain.default

  • convert the input string to a boolean. Everything except for '0', 'false' and '' returns true. In strict mode only '1' and 'true' return true.

    Parameters

    • strict: boolean = false

    Returns ValidationChain.default

  • Remove characters that do not appear in the whitelist. The characters are used in a RegExp and so you will need to escape some chars, e.g. whitelist(input, '\[\]').

    Parameters

    • chars: string

      Characters to whitelist

    Returns ValidationChain.default

Generated using TypeDoc