UNPKG

dynamodb-toolbox

Version:

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

17 lines (16 loc) 696 B
import { ZodBigInt, ZodNumber, ZodString } from 'zod'; import { DynamoDBToolboxError } from '../../../errors/index.js'; import { set } from '../../../schema/set/index.js'; import { fromZodSchema } from './fromZodSchema.js'; export const fromZodSet = (zodSet) => { const { valueType } = zodSet._def; if (!(valueType instanceof ZodNumber || valueType instanceof ZodString || valueType instanceof ZodBigInt)) { throw new DynamoDBToolboxError('fromZodSchema.unsupportedSetValueType', { message: 'Sets can only contain binaries, strings or number', payload: { received: valueType } }); } return set(fromZodSchema(valueType)); };