UNPKG

dynamodb-toolbox

Version:

Lightweight and type-safe query builder for DynamoDB and TypeScript.

11 lines (10 loc) 717 B
import type { ZodOptional, ZodTypeAny } from 'zod'; import type { Schema } from '../../../index.js'; import type { SchemaProps } from '../../../schema/types/schemaProps.js'; import type { Overwrite } from '../../../types/overwrite.js'; import type { FromZodSchema } from './fromZodSchema.js'; export type ZodOptionalAny = ZodOptional<ZodTypeAny>; export type FromZodOptional<ZOD_SCHEMA extends ZodOptional<ZodTypeAny>, ROOT extends boolean = true, PROPS extends SchemaProps = {}> = ZOD_SCHEMA extends ZodOptional<infer UNWRAPPED_ZOD_SCHEMA> ? FromZodSchema<UNWRAPPED_ZOD_SCHEMA, ROOT, Overwrite<PROPS, { required: 'never'; }>> : never; export declare const fromZodOptional: (zodSchema: ZodOptionalAny) => Schema;