---
title: getFallbacks
description: Returns the fallback values of the schema.
source: /methods/getFallbacks/getFallbacks.ts
contributors:
  - fabian-hiller
  - EltonLobo07
---

import { ApiList, Link, Property } from '~/components';
import { properties } from './properties';

# getFallbacks

Returns the fallback values of the schema.

> The difference to <Link href='../getFallback/'>`getFallback`</Link> is that for object and tuple schemas this function recursively returns the fallback values of the subschemas instead of `undefined`.

```ts
const values = v.getFallbacks<TSchema>(schema);
```

## Generics

- `TSchema` <Property {...properties.TSchema} />

## Parameters

- `schema` <Property {...properties.schema} />

## Returns

- `values` <Property {...properties.values} />

## Examples

The following examples show how `getFallbacks` can be used.

### Object fallbacks

Get the fallback values of an object schema.

```ts
const ObjectSchema = v.object({
  key: v.fallback(v.string(), "I'm the fallback!"),
});

const fallbackValues = v.getFallbacks(ObjectSchema); // { key: "I'm the fallback!" }
```

### Tuple fallbacks

Get the fallback values of a tuple schema.

```ts
const TupleSchema = v.tuple([v.fallback(v.number(), 100)]);
const fallbackValues = v.getFallbacks(TupleSchema); // [100]
```

## Related

The following APIs can be combined with `getFallbacks`.

### Schemas

<ApiList
  items={[
    '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

<ApiList
  items={[
    'assert',
    'config',
    'fallback',
    'keyof',
    'message',
    'omit',
    'partial',
    'pick',
    'pipe',
    'required',
    'unwrap',
  ]}
/>
