---
title: parserAsync
description: Returns a function that parses an unknown input based on a schema.
source: /methods/parser/parserAsync.ts
contributors:
  - fabian-hiller
  - EltonLobo07
---

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

# parserAsync

Returns a function that parses an unknown input based on a schema.

```ts
const parser = v.parserAsync<TSchema, TConfig>(schema, config);
```

## Generics

- `TSchema` <Property {...properties.TSchema} />
- `TConfig` <Property {...properties.TConfig} />

## Parameters

- `schema` <Property {...properties.schema} />
- `config` <Property {...properties.config} />

## Returns

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

## Examples

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

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

try {
  const StoredEmailSchema = v.pipeAsync(
    v.string(),
    v.email(),
    v.checkAsync(isEmailPresent, 'The email is not in the database.')
  );
  const storedEmailParser = v.parserAsync(StoredEmailSchema);
  const storedEmail = await storedEmailParser('jane@example.com');

  // Handle errors if one occurs
} catch (error) {
  console.error(error);
}
```

## Related

The following APIs can be combined with `parserAsync`.

### 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',
  ]}
/>

### Methods

<ApiList
  items={[
    'assert',
    'config',
    'fallback',
    'flatten',
    'keyof',
    'message',
    'omit',
    'partial',
    'pick',
    'pipe',
    'required',
    'summarize',
    'unwrap',
  ]}
/>

### Utils

<ApiList items={['getDotPath', 'isValiError', 'ValiError']} />

### Async

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