zaions-tool-kit
Version:
Zaions Tool Kit, this is generic tool kit package created by Zaions Dev Team (https://zaions.com), there are two other packages named "@zaionsofficial/server-tool-kit" and "@zaionsofficial/client-tool-kit" while this package is generic and contains code w
1 lines • 1.03 kB
Source Map (JSON)
{"version":3,"sources":["../../../src/require-package/zod/index.ts"],"names":["numericEnum","values","ZOD","val","ctx"],"mappings":"qDAQO,SAASA,CAAAA,CACdC,EACA,CACA,OAAOC,CAAI,CAAA,MAAA,GAAS,WAAY,CAAA,CAACC,CAAKC,CAAAA,CAAAA,GAAQ,CACvCH,CAAO,CAAA,QAAA,CAASE,CAAG,CAAA,EACtBC,EAAI,QAAS,CAAA,CACX,IAAMF,CAAAA,CAAAA,CAAI,aAAa,kBACvB,CAAA,OAAA,CAAS,CAAC,GAAGD,CAAM,CACnB,CAAA,QAAA,CAAUE,CACZ,CAAC,EAEL,CAAC,CACH","file":"index.mjs","sourcesContent":["import { z as ZOD, ZodType } from 'zod';\n\n/**\n * Create a Zod type for a numeric enum.\n *\n * @param {TValues} values - The values of the enum.\n * @returns {ZodType<TValues[number]>} The Zod type for the enum.\n */\nexport function numericEnum<TValues extends readonly number[]>(\n values: TValues\n) {\n return ZOD.number().superRefine((val, ctx) => {\n if (!values.includes(val)) {\n ctx.addIssue({\n code: ZOD.ZodIssueCode.invalid_enum_value,\n options: [...values],\n received: val,\n });\n }\n }) as ZodType<TValues[number]>;\n}\n"]}