forwardAsync

Forwards the issues of the passed validation action.

const Action = v.forwardAsync<TInput, TIssue>(action, pathKeys);

Generics

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

Parameters

Explanation

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

Returns

Examples

The following examples show how forwardAsync can be used.

Allowed action schema

Schema that checks if the user is allowed to complete an action.

import { isAllowedAction, isUsernamePresent } from '~/api';

const AllowedActionSchema = v.pipeAsync(
  v.objectAsync({
    username: v.pipeAsync(
      v.string(),
      v.minLength(3),
      v.checkAsync(isUsernamePresent, 'The username is not in the database.')
    ),
    action: v.picklist(['view', 'edit', 'delete']),
  }),
  v.forwardAsync(
    v.checkAsync(
      isAllowedAction,
      'The user is not allowed to complete the action.'
    ),
    ['action']
  )
);

The following APIs can be combined with forwardAsync.

Schemas

Methods

Actions

Utils

Async

Contributors

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

  • GitHub profile picture of fabian-hiller
  • GitHub profile picture of EltonLobo07

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 antfu
  • GitHub profile picture of Thanaen
  • GitHub profile picture of osdiab
  • GitHub profile picture of ruiaraujo012
  • GitHub profile picture of hyunbinseo
  • GitHub profile picture of F0rce
  • GitHub profile picture of Unique-Pixels
  • GitHub profile picture of jdgamble555
  • GitHub profile picture of nickytonline
  • GitHub profile picture of KubaJastrz
  • GitHub profile picture of caegdeveloper
  • GitHub profile picture of dslatkin