tupleWithRestAsync
Creates a tuple with rest schema.
const Schema = v.tupleWithRestAsync<TItems, TRest, TMessage>(
items,
rest,
message
);
Generics
TItemsextends TupleItemsAsyncTRestextends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>TMessageextends ErrorMessage<TupleWithRestIssue> | undefined
Parameters
itemsTItemsrestTRestmessageTMessage
Explanation
With tupleWithRestAsync you can validate the data type of the input and whether the content matches items and rest. If the input is not an array, you can use message to customize the error message.
Returns
SchemaTupleWithRestSchemaAsync<TItems, TRest, TMessage>
Examples
The following examples show how tupleWithRestAsync can be used. Please see the arrays guide for more examples and explanations.
Tuple schema with rest
Schema to validate a tuple with generic rest items.
import { isEmailPresent } from '~/api';
const TupleSchemaWithRest = v.tupleWithRestAsync(
[
v.number(),
v.pipeAsync(
v.string(),
v.email(),
v.checkAsync(isEmailPresent, 'The email is not in the database.')
),
],
v.boolean()
);
Related
The following APIs can be combined with tupleWithRestAsync.
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, undefined, undefinedable, union, unknown, variant, void
Methods
config, getDefault, getFallback
Actions
check, checkItems, brand, description, empty, everyItem, excludes, filterItems, findItem, flavor, guard, includes, length, mapItems, maxLength, metadata, minLength, nonEmpty, notLength, partialCheck, rawCheck, rawTransform, readonly, reduceItems, someItem, sortItems, title, transform
Utils
entriesFromList, isOfKind, isOfType
Async
arrayAsync, checkAsync, customAsync, exactOptionalAsync, fallbackAsync, getDefaultsAsync, getFallbacksAsync, intersectAsync, lazyAsync, looseObjectAsync, looseTupleAsync, mapAsync, nonNullableAsync, nonNullishAsync, nonOptionalAsync, nullableAsync, nullishAsync, objectAsync, objectWithRestAsync, optionalAsync, parseAsync, parserAsync, partialCheckAsync, pipeAsync, rawCheckAsync, rawTransformAsync, recordAsync, safeParseAsync, safeParserAsync, setAsync, strictObjectAsync, strictTupleAsync, transformAsync, tupleAsync, unionAsync, variantAsync
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/tupleWithRestAsync/