promise
Creates a promise schema.
const Schema = v.promise<TMessage>(message);
Generics
TMessageextends ErrorMessage<PromiseIssue> | undefined
Parameters
messageTMessage
Explanation
With promise you can validate the data type of the input. If the input is not a promise, you can use message to customize the error message.
Returns
SchemaPromiseSchema<TMessage>
Examples
The following examples show how promise can be used.
Number promise
Schema to validate a promise that resolves to a number.
const NumberPromiseSchema = v.pipeAsync(
v.promise(),
v.awaitAsync(),
v.number()
);
Related
The following APIs can be combined with promise.
Schemas
array, exactOptional, intersect, lazy, looseObject, looseTuple, map, nonNullable, nonNullish, nonOptional, nullable, nullish, object, objectWithRest, optional, record, set, strictObject, strictTuple, tuple, tupleWithRest, undefinedable, union
Methods
assert, config, fallback, getDefault, getDefaults, getFallback, getFallbacks, is, message, parse, parser, pipe, safeParse, safeParser
Actions
awaitAsync, check, brand, description, flavor, guard, metadata, rawCheck, rawTransform, readonly, title, transform
Utils
entriesFromList, isOfKind, isOfType
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/promise/