dynamodb-toolbox
Version:
Lightweight and type-safe query builder for DynamoDB and TypeScript.
15 lines (14 loc) • 650 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.fromZodRecord = void 0;
const zod_1 = require("zod");
const index_js_1 = require("../../../schema/record/index.js");
const fromZodSchema_js_1 = require("./fromZodSchema.js");
const fromZodRecord = (zodRecord) => {
const { keySchema, valueSchema } = zodRecord;
if (!(keySchema instanceof zod_1.ZodString || keySchema instanceof zod_1.ZodEnum)) {
throw new Error();
}
return (0, index_js_1.record)((0, fromZodSchema_js_1.fromZodSchema)(keySchema), (0, fromZodSchema_js_1.fromZodSchema)(valueSchema));
};
exports.fromZodRecord = fromZodRecord;