Spec-Zone.ru › Valibot

looseTupleAsync

Creates a loose tuple schema.

const Schema = v.looseTupleAsync<TItems, TMessage>(items, message);

Generics

  • TItems extends TupleItemsAsync
  • TMessage extends ErrorMessage<LooseTupleIssue> | undefined

Parameters

  • items TItems
  • message TMessage

Explanation

With looseTuplAsynce you can validate the data type of the input and whether the content matches items. If the input is not an array, you can use message to customize the error message.

The difference to tupleAsync is that this schema does include unknown items into the output.

Returns

  • Schema LooseTupleSchemaAsync<TItems, TMessage>

Examples

The following examples show how looseTupleAsync can be used. Please see the arrays guide for more examples and explanations.

Number and email tuple

Schema to validate a loose tuple with one number and one stored email address.

import { isEmailPresent } from '~/api';

const TupleSchema = v.looseTupleAsync([
  v.number(),
  v.pipeAsync(
    v.string(),
    v.email(),
    v.checkAsync(isEmailPresent, 'The email is not in the database.')
  ),
]);

Related

The following APIs can be combined with looseTupleAsync.

Schemas

any, array, bigint, blob, boolean, custom, date, enum, exactOptional, file, function, instance, intersect, lazy, literal, looseObject, 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

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, mapAsync, nonNullableAsync, nonNullishAsync, nonOptionalAsync, nullableAsync, nullishAsync, objectAsync, objectWithRestAsync, optionalAsync, parseAsync, parserAsync, partialCheckAsync, pipeAsync, rawCheckAsync, rawTransformAsync, recordAsync, safeParseAsync, safeParserAsync, setAsync, strictObjectAsync, strictTupleAsync, transformAsync, tupleAsync, tupleWithRestAsync, unionAsync, variantAsync

© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/looseTupleAsync/

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API