UNPKG

dynamodb-toolbox

Version:

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

42 lines (41 loc) 1.64 kB
import { anyZodFormatter } from './any.js'; import { anyOfZodFormatter } from './anyOf.js'; import { binaryZodFormatter } from './binary.js'; import { booleanZodFormatter } from './boolean.js'; import { itemZodFormatter } from './item.js'; import { listZodFormatter } from './list.js'; import { mapZodFormatter } from './map.js'; import { nullZodFormatter } from './null.js'; import { numberZodFormatter } from './number.js'; import { recordZodFormatter } from './record.js'; import { getSetZodFormatter } from './set.js'; import { getStringZodFormatter } from './string.js'; export const schemaZodFormatter = (schema, options = {}) => { switch (schema.type) { case 'any': return anyZodFormatter(schema, options); case 'null': return nullZodFormatter(schema, options); case 'boolean': return booleanZodFormatter(schema, options); case 'number': return numberZodFormatter(schema, options); case 'string': return getStringZodFormatter(schema, options); case 'binary': return binaryZodFormatter(schema, options); case 'set': return getSetZodFormatter(schema, options); case 'list': return listZodFormatter(schema, options); case 'map': return mapZodFormatter(schema, options); case 'record': return recordZodFormatter(schema, options); case 'anyOf': return anyOfZodFormatter(schema, options); case 'item': // NOTE: Should not happen return itemZodFormatter(schema, options); } };