# forward

> This document is the Markdown version of [valibot.dev/api/forward/](https://valibot.dev/api/forward/). For the complete documentation index, see [llms.txt](https://valibot.dev/llms.txt).

Forwards the issues of the passed validation action.

```ts
const Action = v.forward<TInput, TIssue, TPath>(action, path);
```

## Generics

- `TInput` `extends Record<string, unknown> | ArrayLike<unknown>`
- `TIssue` `extends BaseIssue<unknown>`
- `TPath` `extends RequiredPath`

## Parameters

- `action` `BaseValidation<TInput, TInput, TIssue>`
- `path` `ValidPath<TInput, TPath>`

### Explanation

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

## Returns

- `Action` `BaseValidation<TInput, TInput, TIssue>`

## Examples

The following examples show how `forward` can be used.

### Register schema

Schema that ensures that the two passwords match.

```ts
const RegisterSchema = v.pipe(
  v.object({
    email: v.pipe(
      v.string(),
      v.nonEmpty('Please enter your email.'),
      v.email('The email address is badly formatted.')
    ),
    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.partialCheck(
      [['password1'], ['password2']],
      (input) => input.password1 === input.password2,
      'The two passwords do not match.'
    ),
    ['password2']
  )
);
```

## Related

The following APIs can be combined with `forward`.

### Schemas

[`any`](/api/any.md), [`array`](/api/array.md), [`custom`](/api/custom.md), [`looseObject`](/api/looseObject.md), [`looseTuple`](/api/looseTuple.md), [`object`](/api/object.md), [`objectWithRest`](/api/objectWithRest.md), [`record`](/api/record.md), [`strictObject`](/api/strictObject.md), [`strictTuple`](/api/strictTuple.md), [`tuple`](/api/tuple.md), [`tupleWithRest`](/api/tupleWithRest.md), [`union`](/api/union.md), [`unknown`](/api/unknown.md), [`variant`](/api/variant.md)

### Methods

[`omit`](/api/omit.md), [`partial`](/api/partial.md), [`pick`](/api/pick.md), [`pipe`](/api/pipe.md), [`required`](/api/required.md)

### Actions

[`check`](/api/check.md), [`checkItems`](/api/checkItems.md), [`empty`](/api/empty.md), [`everyItem`](/api/everyItem.md), [`excludes`](/api/excludes.md), [`filterItems`](/api/filterItems.md), [`findItem`](/api/findItem.md), [`guard`](/api/guard.md), [`includes`](/api/includes.md), [`length`](/api/length.md), [`mapItems`](/api/mapItems.md), [`maxLength`](/api/maxLength.md), [`metadata`](/api/metadata.md), [`minLength`](/api/minLength.md), [`nonEmpty`](/api/nonEmpty.md), [`notLength`](/api/notLength.md), [`partialCheck`](/api/partialCheck.md), [`rawCheck`](/api/rawCheck.md), [`reduceItems`](/api/reduceItems.md), [`someItem`](/api/someItem.md), [`sortItems`](/api/sortItems.md)

### Utils

[`isOfKind`](/api/isOfKind.md), [`isOfType`](/api/isOfType.md)
