UNPKG

dynamodb-toolbox

Version:

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

13 lines (12 loc) 962 B
import { z } from 'zod'; import type { BooleanSchema, ResolvedBooleanSchema } from '../../../../schema/index.js'; import type { Cast } from '../../../../types/cast.js'; import type { WithValidate } from '../utils.js'; import type { ZodFormatterOptions } from './types.js'; import type { WithDecoding, WithOptional, ZodLiteralMap } from './utils.js'; export type BooleanZodFormatter<SCHEMA extends BooleanSchema, OPTIONS extends ZodFormatterOptions = {}> = WithDecoding<SCHEMA, OPTIONS, WithOptional<SCHEMA, OPTIONS, WithValidate<SCHEMA, SCHEMA['props'] extends { enum: [ResolvedBooleanSchema]; } ? z.ZodLiteral<SCHEMA['props']['enum'][0]> : SCHEMA['props'] extends { enum: [ResolvedBooleanSchema, ...ResolvedBooleanSchema[]]; } ? z.ZodUnion<Cast<ZodLiteralMap<SCHEMA['props']['enum']>, [z.ZodTypeAny, ...z.ZodTypeAny[]]>> : z.ZodBoolean>>>; export declare const booleanZodFormatter: (schema: BooleanSchema, options: ZodFormatterOptions) => z.ZodTypeAny;