Saltearse al contenido

zod-utils

Esta página aún no está disponible en tu idioma.

function deepRemoveDefaults(schema: ZodTypeAny): ZodTypeAny

Defined in: zod-utils.ts:35^

Recursively removes all default values from a given Zod schema.

  • For ZodDefault, it unwraps the default value.
  • For ZodObject, it processes each field and wraps them as optional without defaults.
  • For ZodArray, ZodOptional, ZodNullable, and ZodTuple, it recursively processes their elements/items.
  • For all other schema types, it returns the schema as-is.

ZodTypeAny

The Zod schema to process.

ZodTypeAny

A new Zod schema with all defaults removed and fields made optional where applicable.


function parseAndMerge<T>(
schema: T,
inlineConfig?: T["_output"],
configFile?: T["_input"]): T["_output"]

Defined in: zod-utils.ts:84^

Parses and merges configuration objects using a Zod schema.

This function removes all default values from the provided schema, parses the configFile object with the modified schema, and then deeply merges the result with the inlineConfig object.

If parsing fails, an error is thrown with a descriptive message.

T extends ZodTypeAny

A Zod schema type.

T

The Zod schema to use for validation.

T["_output"]

The inline configuration object, expected to match the schema’s output type.

T["_input"]

The configuration object to parse, expected to match the schema’s input type.

T["_output"]

The merged configuration object, conforming to the schema’s output type.

If parsing the configuration fails.


function parseConfig<T>(schema: T, opts: unknown): T["_output"]

Defined in: zod-utils.ts:13^

Parses and validates the provided configuration options using the given Zod schema.

T extends ZodTypeAny

A Zod schema type extending z.ZodTypeAny.

T

The Zod schema to validate the configuration options against.

unknown

The configuration options to be validated.

T["_output"]

The validated and parsed configuration options as the schema’s output type.

If the configuration options are invalid or if an unknown error occurs during parsing.