intersect
Создаёт схему пересечения.
Рекомендуем прочитать руководство по пересечениям перед использованием этой функции схемы.
const Schema = v.intersect<TOptions, TMessage>(options, message);
Обобщённые типы
TOptionsextends IntersectOptionsTMessageextends ErrorMessage<IntersectIssue> | undefined
Параметры
optionsTOptionsmessageTMessage
Пояснение
С помощью intersect можно проверить, соответствует ли входное значение каждой из заданных options. Если выходные данные пересечения невозможно успешно объединить, можно использовать message для настройки сообщения об ошибке.
Возвращает
SchemaIntersectSchema<TOptions, TMessage>
Примеры
В следующих примерах показано, как можно использовать intersect.
Пересечение объектов
Схема, объединяющая две схемы объектов.
const ObjectSchema = v.intersect([
v.object({ foo: v.string() }),
v.object({ bar: v.number() }),
]);
Связанные API
Следующие API можно комбинировать с intersect.
Схемы
any, array, bigint, blob, boolean, custom, date, enum, exactOptional, file, function, instance, 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
Методы
assert, config, fallback, getDefault, getDefaults, getFallback, getFallbacks, is, message, parse, parser, pipe, safeParse, safeParser
Действия
args, base64, bic, brand, bytes, check, checkItems, codePoints, creditCard, cuid2, decimal, description, digits, domain, email, emoji, empty, endsWith, entries, everyItem, excludes, filterItems, findItem, finite, flavor, graphemes, gtValue, guard, hash, hexadecimal, hexColor, imei, includes, integer, ip, ipv4, ipv6, isbn, isrc, isoDate, isoDateTime, isoDateTimeSecond, isoTime, isoTimeSecond, isoTimestamp, isoWeek, ksuid, length, ltValue, mac, mac48, mac64, mapItems, maxBytes, maxCodePoints, maxEntries, maxGraphemes, maxLength, maxSize, maxValue, maxWords, metadata, mimeType, minBytes, minCodePoints, minEntries, minGraphemes, minLength, minSize, minValue, minWords, multipleOf, nanoid, nonEmpty, notBytes, notCodePoints, notEntries, notGraphemes, notLength, notSize, notValue, notValues, notWords, octal, parseJson, partialCheck, rawCheck, rawTransform, readonly, reduceItems, regex, returns, rfcEmail, safeInteger, size, slug, someItem, sortItems, startsWith, stringifyJson, title, toCamelCase, toKebabCase, toLowerCase, toMaxValue, toMinValue, toPascalCase, toSnakeCase, toUpperCase, transform, trim, trimEnd, trimStart, ulid, url, uuid, value, values, words
Утилиты
entriesFromList, isOfKind, isOfType
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/intersect/