UNPKG

dynamodb-toolbox

Version:

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

42 lines (41 loc) 1.56 kB
import { anyZodParser } from './any.js'; import { anyOfZodParser } from './anyOf.js'; import { binaryZodParser } from './binary.js'; import { booleanZodParser } from './boolean.js'; import { itemZodParser } from './item.js'; import { listZodParser } from './list.js'; import { mapZodParser } from './map.js'; import { nullZodParser } from './null.js'; import { numberZodParser } from './number.js'; import { recordZodParser } from './record.js'; import { getSetZodParser } from './set.js'; import { getStringZodParser } from './string.js'; export const schemaZodParser = (schema, options = {}) => { switch (schema.type) { case 'any': return anyZodParser(schema, options); case 'null': return nullZodParser(schema, options); case 'boolean': return booleanZodParser(schema, options); case 'number': return numberZodParser(schema, options); case 'string': return getStringZodParser(schema, options); case 'binary': return binaryZodParser(schema, options); case 'set': return getSetZodParser(schema, options); case 'list': return listZodParser(schema, options); case 'map': return mapZodParser(schema, options); case 'record': return recordZodParser(schema, options); case 'anyOf': return anyOfZodParser(schema, options); case 'item': // NOTE: Should not happen return itemZodParser(schema, options); } };