awaitAsync
Creates an await transformation action.
const Action = v.awaitAsync<TInput>();
Generics
TInputextends Promise<unknown>
Explanation
With awaitAsync you can transform a promise into its resolved value.
Returns
ActionAwaitActionAsync<TInput>
Examples
The following examples show how awaitAsync can be used.
Unique emails schema
Schema to check a set of emails wrapped in a promise object.
const UniqueEmailsSchema = v.pipeAsync(
v.promise(),
v.awaitAsync(),
v.set(v.pipe(v.string(), v.email()))
);
Related
The following APIs can be combined with awaitAsync.
Schemas
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
Async
arrayAsync, customAsync, exactOptionalAsync, intersectAsync, lazyAsync, looseObjectAsync, looseTupleAsync, mapAsync, nonNullableAsync, nonNullishAsync, nonOptionalAsync, nullableAsync, nullishAsync, objectAsync, objectWithRestAsync, optionalAsync, pipeAsync, recordAsync, setAsync, strictObjectAsync, strictTupleAsync, tupleAsync, tupleWithRestAsync, unionAsync, variantAsync
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/awaitAsync/