UNPKG

dynamodb-toolbox

Version:

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

21 lines (20 loc) 877 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fromZodSet = void 0; const zod_1 = require("zod"); const index_js_1 = require("../../../errors/index.js"); const index_js_2 = require("../../../schema/set/index.js"); const fromZodSchema_js_1 = require("./fromZodSchema.js"); const fromZodSet = (zodSet) => { const { valueType } = zodSet._def; if (!(valueType instanceof zod_1.ZodNumber || valueType instanceof zod_1.ZodString || valueType instanceof zod_1.ZodBigInt)) { throw new index_js_1.DynamoDBToolboxError('fromZodSchema.unsupportedSetValueType', { message: 'Sets can only contain binaries, strings or number', payload: { received: valueType } }); } return (0, index_js_2.set)((0, fromZodSchema_js_1.fromZodSchema)(valueType)); }; exports.fromZodSet = fromZodSet;