{"version":3,"file":"errorMessages.cjs","names":["res: T","key: keyof T","errorMessage: string | undefined","refs: Refs","res: Json7Type","key: Key","value: Json7Type[Key]"],"sources":["../../../src/utils/zod-to-json-schema/errorMessages.ts"],"sourcesContent":["import { JsonSchema7TypeUnion } from \"./parseTypes.js\";\nimport { Refs } from \"./Refs.js\";\n\nexport type ErrorMessages<\n  T extends JsonSchema7TypeUnion | { format: string } | { pattern: string },\n  OmitProperties extends string = \"\",\n> = Partial<\n  Omit<{ [key in keyof T]: string }, OmitProperties | \"type\" | \"errorMessages\">\n>;\n\nexport function addErrorMessage<\n  T extends { errorMessage?: ErrorMessages<any> },\n>(res: T, key: keyof T, errorMessage: string | undefined, refs: Refs) {\n  if (!refs?.errorMessages) return;\n  if (errorMessage) {\n    res.errorMessage = {\n      ...res.errorMessage,\n      [key]: errorMessage,\n    };\n  }\n}\n\nexport function setResponseValueAndErrors<\n  Json7Type extends JsonSchema7TypeUnion & {\n    errorMessage?: ErrorMessages<Json7Type>;\n  },\n  Key extends keyof Omit<Json7Type, \"errorMessage\">,\n>(\n  res: Json7Type,\n  key: Key,\n  value: Json7Type[Key],\n  errorMessage: string | undefined,\n  refs: Refs,\n) {\n  res[key] = value;\n  addErrorMessage(res, key, errorMessage, refs);\n}\n"],"mappings":";;AAUA,SAAgB,gBAEdA,KAAQC,KAAcC,cAAkCC,MAAY;AACpE,KAAI,CAAC,MAAM,cAAe;AAC1B,KAAI,cACF,IAAI,eAAe;EACjB,GAAG,IAAI;GACN,MAAM;CACR;AAEJ;AAED,SAAgB,0BAMdC,KACAC,KACAC,OACAJ,cACAC,MACA;CACA,IAAI,OAAO;CACX,gBAAgB,KAAK,KAAK,cAAc,KAAK;AAC9C"}