# partialCheck

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

Creates a partial check validation action.

```ts
const Action = v.partialCheck<TInput, TPaths, TSelection, TMessage>(
  paths,
  requirement,
  message
);
```

## Generics

- `TInput` `extends Record<string, unknown> | ArrayLike<unknown>`
- `TPaths` `extends RequiredPaths`
- `TSelection` `extends DeepPickN<TInput, TPaths>`
- `TMessage` `extends ErrorMessage<PartialCheckIssue<TSelection>> | undefined`

## Parameters

- `paths` `ValidPaths<TInput, TPaths>`
- `requirement` `(input: TSelection) => boolean`
- `message` `TMessage`

### Explanation

With `partialCheck` you can freely validate the selected input and return `true` if it is valid or `false` otherwise. If the input does not match your `requirement`, you can use `message` to customize the error message.

> The difference to [`check`](/api/check.md) is that `partialCheck` can be executed whenever the selected part of the data is valid, while [`check`](/api/check.md) is executed only when the entire dataset is typed. This can be an important advantage when working with forms.

## Returns

- `Action` `PartialCheckAction<TInput, TPaths, TSelection, TMessage>`

## Examples

The following examples show how `partialCheck` 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 `partialCheck`.

### Schemas

[`any`](/api/any.md), [`array`](/api/array.md), [`custom`](/api/custom.md), [`instance`](/api/instance.md), [`intersect`](/api/intersect.md), [`lazy`](/api/lazy.md), [`looseObject`](/api/looseObject.md), [`looseTuple`](/api/looseTuple.md), [`nonNullable`](/api/nonNullable.md), [`nonNullish`](/api/nonNullish.md), [`nonOptional`](/api/nonOptional.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), [`variant`](/api/variant.md)

### Methods

[`forward`](/api/forward.md), [`pipe`](/api/pipe.md)

### Utils

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