---
title: checkAsync
description: Creates a check validation action.
source: /actions/check/checkAsync.ts
contributors:
  - fabian-hiller
  - EltonLobo07
---

import { ApiList, Property } from '~/components';
import { properties } from './properties';

# checkAsync

Creates a check validation action.

```ts
const Action = v.checkAsync<TInput, TMessage>(requirement, message);
```

## Generics

- `TInput` <Property {...properties.TInput} />
- `TMessage` <Property {...properties.TMessage} />

## Parameters

- `requirement` <Property {...properties.requirement} />
- `message` <Property {...properties.message} />

### Explanation

With `checkAsync` you can freely validate the 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.

## Returns

- `Action` <Property {...properties.Action} />

## Examples

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

### Cart item schema

Schema to check a cart item object.

```ts
import { getProductItem } from '~/api';

const CartItemSchema = v.pipeAsync(
  v.object({
    itemId: v.pipe(v.string(), v.regex(/^[a-z0-9]{10}$/i)),
    quantity: v.pipe(v.number(), v.minValue(1)),
  }),
  v.checkAsync(async (input) => {
    const productItem = await getProductItem(input.itemId);
    return productItem?.quantity >= input.quantity;
  }, 'The required quantity is greater than available.')
);
```

## Related

The following APIs can be combined with `checkAsync`.

### Schemas

<ApiList
  items={[
    'any',
    'array',
    'bigint',
    'blob',
    'boolean',
    'custom',
    'date',
    'enum',
    'exactOptional',
    'file',
    'function',
    'instance',
    'intersect',
    'lazy',
    'literal',
    'looseObject',
    'looseTuple',
    'map',
    'nan',
    'never',
    'nonNullable',
    'nonNullish',
    'nonOptional',
    'null',
    'nullable',
    'nullish',
    'number',
    'object',
    'objectWithRest',
    'optional',
    'picklist',
    'promise',
    'record',
    'set',
    'strictObject',
    'strictTuple',
    'string',
    'symbol',
    'tuple',
    'tupleWithRest',
    'undefined',
    'undefinedable',
    'union',
    'unknown',
    'variant',
    'void',
  ]}
/>

### Utils

<ApiList items={['isOfKind', 'isOfType']} />

### Async

<ApiList
  items={[
    'arrayAsync',
    'awaitAsync',
    'customAsync',
    'exactOptionalAsync',
    'intersectAsync',
    'lazyAsync',
    'looseObjectAsync',
    'looseTupleAsync',
    'mapAsync',
    'nonNullableAsync',
    'nonNullishAsync',
    'nonOptionalAsync',
    'nullableAsync',
    'nullishAsync',
    'objectAsync',
    'objectWithRestAsync',
    'optionalAsync',
    'pipeAsync',
    'recordAsync',
    'setAsync',
    'strictObjectAsync',
    'strictTupleAsync',
    'tupleAsync',
    'tupleWithRestAsync',
    'unionAsync',
    'variantAsync',
  ]}
/>
