Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/valibot/mod.ts>getDefaultsAsync

The modular and type safe schema library for validating structural data 🤖
Extremely Popular
Latest
function getDefaultsAsync
import { getDefaultsAsync } from "https://deno.land/x/valibot@v1.0.0-beta.1-i18n/mod.ts";

Returns the default values of the schema.

Hint: The difference to getDefault is that for object and tuple schemas this function recursively returns the default values of the subschemas instead of undefined.

Type Parameters

TSchema extends
| BaseSchema<unknown, unknown, BaseIssue<unknown>>
| BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>
| LooseObjectSchema<ObjectEntries, ErrorMessage<LooseObjectIssue> | undefined>
| LooseObjectSchemaAsync<ObjectEntriesAsync, ErrorMessage<LooseObjectIssue> | undefined>
| LooseTupleSchema<TupleItems, ErrorMessage<LooseTupleIssue> | undefined>
| LooseTupleSchemaAsync<TupleItemsAsync, ErrorMessage<LooseTupleIssue> | undefined>
| ObjectSchema<ObjectEntries, ErrorMessage<ObjectIssue> | undefined>
| ObjectSchemaAsync<ObjectEntriesAsync, ErrorMessage<ObjectIssue> | undefined>
| ObjectWithRestSchema<ObjectEntries, BaseSchema<unknown, unknown, BaseIssue<unknown>>, ErrorMessage<ObjectWithRestIssue> | undefined>
| ObjectWithRestSchemaAsync<ObjectEntriesAsync, BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, ErrorMessage<ObjectWithRestIssue> | undefined>
| StrictObjectSchema<ObjectEntries, ErrorMessage<StrictObjectIssue> | undefined>
| StrictObjectSchemaAsync<ObjectEntriesAsync, ErrorMessage<StrictObjectIssue> | undefined>
| StrictTupleSchema<TupleItems, ErrorMessage<StrictTupleIssue> | undefined>
| StrictTupleSchemaAsync<TupleItemsAsync, ErrorMessage<StrictTupleIssue> | undefined>
| TupleSchema<TupleItems, ErrorMessage<TupleIssue> | undefined>
| TupleSchemaAsync<TupleItemsAsync, ErrorMessage<TupleIssue> | undefined>
| TupleWithRestSchema<TupleItems, BaseSchema<unknown, unknown, BaseIssue<unknown>>, ErrorMessage<TupleWithRestIssue> | undefined>
| TupleWithRestSchemaAsync<TupleItemsAsync, BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, ErrorMessage<TupleWithRestIssue> | undefined>

Parameters

schema: TSchema

The schema to get them from.

Returns

Promise<InferDefaults<TSchema>>

The default values.