forward

Forwards the issues of the passed validation action.

const Validation = forward<TInput>(validation, pathList);

Generics

  • TInput extends unknown[] | Record<unknown>

Parameters

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 = object(
  {
    password1: string([
      minLength(1, 'Please enter your password.'),
      minLength(8, 'Your password must have 8 characters or more.'),
    ]),
    password2: string(),
  },
  [
    forward(
      custom(
        (input) => input.password1 === input.password2,
        'The two passwords do not match.'
      ),
      ['password2']
    ),
  ]
);

The following APIs can be combined with forward.

Schemas

Methods

Validations

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 ivan-mihalic
  • 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