@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 960 B
Source Map (JSON)
{"version":3,"file":"validate.mjs","names":["zv"],"sources":["../../../../src/libs/http/middleware/validate.ts"],"sourcesContent":["import type { ValidationTargets } from \"hono\";\nimport type { ZodType } from \"zod\";\nimport { LucidAPIError } from \"../../../utils/errors/index.js\";\nimport { copy } from \"../../i18n/index.js\";\nimport { zValidator as zv } from \"./z-validator.js\";\n\nconst validate = <T extends ZodType, Target extends keyof ValidationTargets>(\n\ttarget: Target,\n\tschema: T,\n) =>\n\tzv(target, schema, (result) => {\n\t\tif (!result.success) {\n\t\t\tthrow new LucidAPIError({\n\t\t\t\ttype: \"validation\",\n\t\t\t\tmessage: copy(\"server:core.errors.validation.message\"),\n\t\t\t\tzod: result.error,\n\t\t\t});\n\t\t}\n\t});\n\nexport default validate;\n"],"mappings":"mJAMA,MAAM,GACL,EACA,IAEAA,EAAG,EAAQ,EAAS,GAAW,CAC9B,GAAI,CAAC,EAAO,QACX,MAAM,IAAI,EAAc,CACvB,KAAM,aACN,QAAS,EAAK,uCAAuC,EACrD,IAAK,EAAO,KACb,CAAC,CAEH,CAAC"}