UNPKG

dynamodb-toolbox

Version:

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

15 lines (14 loc) 1.04 kB
import { z } from 'zod'; import type { NumberSchema, ResolvedNumberSchema } 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 NumberZodFormatter<SCHEMA extends NumberSchema, OPTIONS extends ZodFormatterOptions = {}> = WithDecoding<SCHEMA, OPTIONS, WithOptional<SCHEMA, OPTIONS, WithValidate<SCHEMA, SCHEMA['props'] extends { enum: [ResolvedNumberSchema]; } ? z.ZodLiteral<SCHEMA['props']['enum'][0]> : SCHEMA['props'] extends { enum: [ResolvedNumberSchema, ...ResolvedNumberSchema[]]; } ? z.ZodUnion<Cast<ZodLiteralMap<SCHEMA['props']['enum']>, [z.ZodTypeAny, ...z.ZodTypeAny[]]>> : SCHEMA['props'] extends { big: true; } ? z.ZodUnion<[z.ZodNumber, z.ZodBigInt]> : z.ZodNumber>>>; export declare const numberZodFormatter: (schema: NumberSchema, options?: ZodFormatterOptions) => z.ZodTypeAny;