UNPKG

dynamodb-toolbox

Version:

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

17 lines (16 loc) 1.08 kB
import { z } from 'zod'; import type { Schema, TupleSchema } from '../../../../schema/index.js'; import type { Overwrite } from '../../../../types/overwrite.js'; import type { WithValidate } from '../utils.js'; import type { SchemaZodParser } from './schema.js'; import type { ZodParserOptions } from './types.js'; import type { SchemaZodParserRec, WithDefault, WithOptional } from './utils.js'; export type TupleZodParser<SCHEMA extends TupleSchema, OPTIONS extends ZodParserOptions = {}> = TupleSchema extends SCHEMA ? z.ZodTypeAny : WithDefault<SCHEMA, OPTIONS, WithOptional<SCHEMA, OPTIONS, WithValidate<SCHEMA, SCHEMA['elements'] extends [infer SCHEMAS_HEAD, ...infer SCHEMAS_TAIL] ? SCHEMAS_HEAD extends Schema ? SCHEMAS_TAIL extends Schema[] ? z.ZodTuple<[ SchemaZodParser<SCHEMAS_HEAD, Overwrite<OPTIONS, { defined: true; }>>, ...SchemaZodParserRec<SCHEMAS_TAIL, Overwrite<OPTIONS, { defined: true; }>> ]> : never : never : z.ZodTypeAny>>>; export declare const tupleZodParser: (schema: TupleSchema, options?: ZodParserOptions) => z.ZodTypeAny;