Skip to content

Commit

Permalink
Add content to missing API references on website
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian-hiller committed Jan 4, 2025
1 parent f4d2544 commit e72f2e4
Show file tree
Hide file tree
Showing 11 changed files with 1,262 additions and 5 deletions.
97 changes: 96 additions & 1 deletion website/src/routes/api/(async)/argsAsync/index.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,105 @@
---
title: argsAsync
description: Creates a function arguments transformation action.
source: /actions/args/argsAsync.ts
contributors:
- fabian-hiller
---

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

# argsAsync

> The content of this page is not yet ready. Until then, please use the [source code](https://github.com/fabian-hiller/valibot/blob/main/library/src/actions/args/argsAsync.ts) or take a look at [issue #287](https://github.com/fabian-hiller/valibot/issues/287) to help us extend the API reference.
Creates a function arguments transformation action.

```ts
const Action = v.argsAsync<TInput, TSchema>(schema);
```

## Generics

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

## Parameters

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

### Explanation

With `argsAsync` you can force the arguments of a function to match the given `schema`.

## Returns

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

## Examples

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

### Product function schema

Schema of a function that returns a product by its ID.

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

const ProductFunctionSchema = v.pipeAsync(
v.function(),
v.argsAsync(
v.tupleAsync([v.pipeAsync(v.string(), v.checkAsync(isValidProductId))])
),
v.returnsAsync(
v.pipeAsync(
v.promise(),
v.awaitAsync(),
v.object({
id: v.string(),
name: v.string(),
price: v.number(),
})
)
)
);
```

## Related

The following APIs can be combined with `argsAsync`.

### Schemas

<ApiList
items={[
'any',
'custom',
'looseTuple',
'function',
'strictTuple',
'tuple',
'tupleWithRest',
]}
/>

### Methods

<ApiList items={['pipe']} />

### Utils

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

### Async

<ApiList
items={[
'customAsync',
'looseTupleAsync',
'pipeAsync',
'returnsAsync',
'strictTupleAsync',
'tupleAsync',
'tupleWithRestAsync',
]}
/>
Loading

0 comments on commit e72f2e4

Please sign in to comment.