transformAsync

Creates a custom transformation action.

const Action = v.transformAsync<TInput, TOutput>(operation);

Generics

  • TInput extends any
  • TOutput extends any

Parameters

  • operation (input: TInput) => Promise<TOutput>

Explanation

transformAsync can be used to freely transform the input. The operation parameter is a function that takes the input and returns the transformed output.

Returns

Examples

The following examples show how transformAsync can be used.

Blob to string

Schema that transforms a blob to its string value.

const StringSchema = v.pipeAsync(
  v.blob(),
  v.transformAsync((value) => value.text())
);

The following APIs can be combined with transformAsync.

Schemas

Utils

Async

Contributors

Thanks to all the contributors who helped make this page better!

  • GitHub profile picture of fabian-hiller
  • GitHub profile picture of santoshyadavdev
  • GitHub profile picture of EltonLobo07

Partners

Thanks to our partners who support the project ideally and financially.

Sponsors

Thanks to our GitHub sponsors who support the project financially.

  • GitHub profile picture of antfu
  • GitHub profile picture of Thanaen
  • GitHub profile picture of osdiab
  • GitHub profile picture of ruiaraujo012
  • GitHub profile picture of hyunbinseo
  • GitHub profile picture of F0rce
  • GitHub profile picture of Unique-Pixels
  • GitHub profile picture of jdgamble555
  • GitHub profile picture of nickytonline
  • GitHub profile picture of KubaJastrz
  • GitHub profile picture of caegdeveloper
  • GitHub profile picture of dslatkin