forward

Forwards the issues of the passed validation action.

const Action = forward<TInput, TIssue>(action, pathList);

Generics

  • TInput extends Record<string, unknown> | unknown[]
  • TIssue extends BaseIssue<unknown>

Parameters

  • action BaseValidation<TInput, TInput, TIssue>
  • pathList PathList<TInput>

Explanation

forward allows you to forward the issues of the passed validation action via a pathList to a nested field of a schema.

Returns

Examples

The following examples show how forward can be used.

Password schema

Schema that ensures that the two passwords match.

const PasswordSchema = v.pipe(
  v.object({
    password1: v.pipe(
      v.string(),
      v.nonEmpty('Please enter your password.'),
      v.minLength(8, 'Your password must have 8 characters or more.')
    ),
    password2: v.string(),
  }),
  v.forward(
    v.check(
      (input) => input.password1 === input.password2,
      'The two passwords do not match.'
    ),
    ['password2']
  )
);

The following APIs can be combined with forward.

Schemas

Methods

Actions

Contributors

Thanks to all the contributors who helped make this page better!

  • GitHub profile picture of fabian-hiller

Partners

Thanks to our partners who support the project ideally and financially.

Sponsors

Thanks to our GitHub sponsors who support the project financially.

  • GitHub profile picture of dailydotdev
  • GitHub profile picture of KATT
  • GitHub profile picture of osdiab
  • GitHub profile picture of Thanaen
  • GitHub profile picture of ruiaraujo012
  • GitHub profile picture of hyunbinseo
  • GitHub profile picture of caegdeveloper
  • GitHub profile picture of seahindeniz