Spec-Zone.ru › Valibot

getFallback

Returns the fallback value of the schema.

const value = v.getFallback<TSchema>(schema, dataset, config);

Generics

  • TSchema extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>

Parameters

  • schema TSchema
  • dataset OutputDataset<InferOutput<TSchema>, InferIssue<TSchema>> | undefined
  • config Config<InferIssue<TSchema>> | undefined

Returns

  • value InferFallback<TSchema>

Examples

The following examples show how getFallback can be used.

Fallback string schema

Get the fallback value of a string schema.

const FallbackStringSchema = v.fallback(v.string(), "I'm the fallback!");
const fallbackValue = v.getFallback(FallbackStringSchema); // "I'm the fallback!"

Related

The following APIs can be combined with getFallback.

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

Methods

assert, config, fallback, keyof, message, omit, partial, pick, pipe, required, unwrap

Async

arrayAsync, customAsync, exactOptionalAsync, fallbackAsync, intersectAsync, lazyAsync, looseObjectAsync, looseTupleAsync, mapAsync, nonNullableAsync, nonNullishAsync, nonOptionalAsync, nullableAsync, nullishAsync, objectAsync, objectWithRestAsync, optionalAsync, partialAsync, pipeAsync, recordAsync, requiredAsync, setAsync, strictObjectAsync, strictTupleAsync, tupleAsync, tupleWithRestAsync, unionAsync, variantAsync

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

Spec-Zone.ru

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