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

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

# rawCheckAsync

Creates a raw check validation action.

```ts
const Action = v.rawCheckAsync<TInput>(action);
```

## Generics

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

## Parameters

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

### Explanation

With `rawCheckAsync` you can freely validate the input with a custom `action` and add issues if necessary.

## Returns

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

## Examples

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

### Add users schema

Object schema that ensures that only users not already in the group are included.

> This `rawCheckAsync` validation action adds an issue for any invalid username and forwards it via `path` to the appropriate nested field.

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

const AddUsersSchema = v.pipeAsync(
  v.object({
    groupId: v.pipe(v.string(), v.uuid()),
    usernames: v.array(v.pipe(v.string(), v.nonEmpty())),
  }),
  v.rawCheckAsync(async ({ dataset, addIssue }) => {
    if (dataset.typed) {
      await Promise.all(
        dataset.value.usernames.map(async (username, index) => {
          if (await isAlreadyInGroup(username, dataset.value.groupId)) {
            addIssue({
              received: username,
              message: 'The user is already in the group.',
              path: [
                {
                  type: 'object',
                  origin: 'value',
                  input: dataset.value,
                  key: 'usernames',
                  value: dataset.value.usernames,
                },
                {
                  type: 'array',
                  origin: 'value',
                  input: dataset.value.usernames,
                  key: index,
                  value: username,
                },
              ],
            });
          }
        })
      );
    }
  })
);
```

## Related

The following APIs can be combined with `rawCheckAsync`.

### 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',
    'forwardAsync',
    'intersectAsync',
    'lazyAsync',
    'looseObjectAsync',
    'looseTupleAsync',
    'mapAsync',
    'nonNullableAsync',
    'nonNullishAsync',
    'nonOptionalAsync',
    'nullableAsync',
    'nullishAsync',
    'objectAsync',
    'objectWithRestAsync',
    'optionalAsync',
    'pipeAsync',
    'recordAsync',
    'setAsync',
    'strictObjectAsync',
    'strictTupleAsync',
    'tupleAsync',
    'tupleWithRestAsync',
    'undefinedableAsync',
    'unionAsync',
    'variantAsync',
  ]}
/>
