# rawTransformAsync

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

Creates a raw transformation action.

```ts
const Action = v.rawTransformAsync<TInput, TOutput>(action);
```

## Generics

- `TInput` `extends any`
- `TOutput` `extends any`

## Parameters

- `action` `(context: Context<TInput>) => MaybePromise<TOutput>`

### Explanation

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

## Returns

- `Action` `RawTransformActionAsync<TInput, TOutput>`

## Examples

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

### Order schema

Schema that rejects an order that does not meet a requirement when free delivery is expected.

```ts
import { getTotalAmount } from '~/api';
import { FREE_DELIVERY_MIN_AMOUNT } from '~/constants';

const OrderSchema = v.pipeAsync(
  v.object({
    cart: v.array(
      v.object({
        itemId: v.pipe(v.string(), v.uuid()),
        quantity: v.pipe(v.number(), v.integer(), v.minValue(1)),
      })
    ),
    expectsFreeDelivery: v.optional(v.boolean(), false),
  }),
  v.rawTransformAsync(
    async ({ dataset: { value: input }, addIssue, NEVER }) => {
      const total = await getTotalAmount(input.cart);
      if (input.expectsFreeDelivery && total < FREE_DELIVERY_MIN_AMOUNT) {
        addIssue({
          label: 'order',
          expected: `>=${FREE_DELIVERY_MIN_AMOUNT}`,
          received: `${total}`,
          message: `The total amount must be at least $${FREE_DELIVERY_MIN_AMOUNT} for free delivery.`,
          path: [
            {
              type: 'object',
              origin: 'value',
              input,
              key: 'cart',
              value: input.cart,
            },
          ],
        });
        return NEVER;
      }
      return { ...input, total };
    }
  )
);
```

## Related

The following APIs can be combined with `rawTransformAsync`.

### Schemas

[`any`](/api/any.md), [`array`](/api/array.md), [`bigint`](/api/bigint.md), [`blob`](/api/blob.md), [`boolean`](/api/boolean.md), [`custom`](/api/custom.md), [`date`](/api/date.md), [`enum`](/api/enum.md), [`exactOptional`](/api/exactOptional.md), [`file`](/api/file.md), [`function`](/api/function.md), [`instance`](/api/instance.md), [`intersect`](/api/intersect.md), [`lazy`](/api/lazy.md), [`literal`](/api/literal.md), [`looseObject`](/api/looseObject.md), [`looseTuple`](/api/looseTuple.md), [`map`](/api/map.md), [`nan`](/api/nan.md), [`never`](/api/never.md), [`nonNullable`](/api/nonNullable.md), [`nonNullish`](/api/nonNullish.md), [`nonOptional`](/api/nonOptional.md), [`null`](/api/null.md), [`nullable`](/api/nullable.md), [`nullish`](/api/nullish.md), [`number`](/api/number.md), [`object`](/api/object.md), [`objectWithRest`](/api/objectWithRest.md), [`optional`](/api/optional.md), [`picklist`](/api/picklist.md), [`promise`](/api/promise.md), [`record`](/api/record.md), [`set`](/api/set.md), [`strictObject`](/api/strictObject.md), [`strictTuple`](/api/strictTuple.md), [`string`](/api/string.md), [`symbol`](/api/symbol.md), [`tuple`](/api/tuple.md), [`tupleWithRest`](/api/tupleWithRest.md), [`undefined`](/api/undefined.md), [`undefinedable`](/api/undefinedable.md), [`union`](/api/union.md), [`unknown`](/api/unknown.md), [`variant`](/api/variant.md), [`void`](/api/void.md)

### Utils

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

### Async

[`arrayAsync`](/api/arrayAsync.md), [`customAsync`](/api/customAsync.md), [`exactOptionalAsync`](/api/exactOptionalAsync.md), [`forwardAsync`](/api/forwardAsync.md), [`intersectAsync`](/api/intersectAsync.md), [`lazyAsync`](/api/lazyAsync.md), [`looseObjectAsync`](/api/looseObjectAsync.md), [`looseTupleAsync`](/api/looseTupleAsync.md), [`mapAsync`](/api/mapAsync.md), [`nonNullableAsync`](/api/nonNullableAsync.md), [`nonNullishAsync`](/api/nonNullishAsync.md), [`nonOptionalAsync`](/api/nonOptionalAsync.md), [`nullableAsync`](/api/nullableAsync.md), [`nullishAsync`](/api/nullishAsync.md), [`objectAsync`](/api/objectAsync.md), [`objectWithRestAsync`](/api/objectWithRestAsync.md), [`optionalAsync`](/api/optionalAsync.md), [`pipeAsync`](/api/pipeAsync.md), [`recordAsync`](/api/recordAsync.md), [`setAsync`](/api/setAsync.md), [`strictObjectAsync`](/api/strictObjectAsync.md), [`strictTupleAsync`](/api/strictTupleAsync.md), [`tupleAsync`](/api/tupleAsync.md), [`tupleWithRestAsync`](/api/tupleWithRestAsync.md), [`undefinedableAsync`](/api/undefinedableAsync.md), [`unionAsync`](/api/unionAsync.md), [`variantAsync`](/api/variantAsync.md)
