UNPKG

dynamodb-toolbox

Version:

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

15 lines (14 loc) 1.07 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 { ZodParserOptions } from './types.js'; import type { WithDefault, WithEncoding, WithOptional, ZodLiteralMap } from './utils.js'; export type NumberZodParser<SCHEMA extends NumberSchema, OPTIONS extends ZodParserOptions = {}> = WithEncoding<SCHEMA, OPTIONS, WithDefault<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 numberZodParser: (schema: NumberSchema, options?: ZodParserOptions) => z.ZodTypeAny;