zod-utils
Esta página aún no está disponible en tu idioma.
Functions
Section titled “Functions”deepRemoveDefaults()
Section titled “deepRemoveDefaults()”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
, andZodTuple
, it recursively processes their elements/items. - For all other schema types, it returns the schema as-is.
Parameters
Section titled “Parameters”schema
Section titled “schema”ZodTypeAny
The Zod schema to process.
Returns
Section titled “Returns”ZodTypeAny
A new Zod schema with all defaults removed and fields made optional where applicable.
parseAndMerge()
Section titled “parseAndMerge()”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.
Type Parameters
Section titled “Type Parameters”T
extends ZodTypeAny
A Zod schema type.
Parameters
Section titled “Parameters”schema
Section titled “schema”T
The Zod schema to use for validation.
inlineConfig?
Section titled “inlineConfig?”T
["_output"
]
The inline configuration object, expected to match the schema’s output type.
configFile?
Section titled “configFile?”T
["_input"
]
The configuration object to parse, expected to match the schema’s input type.
Returns
Section titled “Returns”T
["_output"
]
The merged configuration object, conforming to the schema’s output type.
Throws
Section titled “Throws”If parsing the configuration fails.
parseConfig()
Section titled “parseConfig()”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.
Type Parameters
Section titled “Type Parameters”T
extends ZodTypeAny
A Zod schema type extending z.ZodTypeAny
.
Parameters
Section titled “Parameters”schema
Section titled “schema”T
The Zod schema to validate the configuration options against.
unknown
The configuration options to be validated.
Returns
Section titled “Returns”T
["_output"
]
The validated and parsed configuration options as the schema’s output type.
Throws
Section titled “Throws”If the configuration options are invalid or if an unknown error occurs during parsing.