@alextheman/utility 4.7.0 → 4.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -878,7 +878,16 @@ function parseZodSchema(schema, data, onError) {
878
878
  if (evaluatedError instanceof Error) throw evaluatedError;
879
879
  }
880
880
  }
881
- throw new DataError_default(data, parsedResult.error.issues[0]?.code?.toUpperCase(), parsedResult.error.issues[0]?.message);
881
+ const allErrorCodes = {};
882
+ for (const issue of parsedResult.error.issues) {
883
+ const code = issue.code.toUpperCase();
884
+ allErrorCodes[code] = (allErrorCodes[code] ?? 0) + 1;
885
+ }
886
+ throw new DataError_default(data, Object.entries(allErrorCodes).toSorted(([_, firstCount], [__, secondCount]) => {
887
+ return secondCount - firstCount;
888
+ }).map(([code, count], _, allErrorCodes$1) => {
889
+ return allErrorCodes$1.length === 1 && count === 1 ? code : `${code}×${count}`;
890
+ }).join(","), `\n\n${zod.z.prettifyError(parsedResult.error)}\n`);
882
891
  }
883
892
  return parsedResult.data;
884
893
  }
package/dist/index.js CHANGED
@@ -848,7 +848,16 @@ function parseZodSchema(schema, data, onError) {
848
848
  if (evaluatedError instanceof Error) throw evaluatedError;
849
849
  }
850
850
  }
851
- throw new DataError_default(data, parsedResult.error.issues[0]?.code?.toUpperCase(), parsedResult.error.issues[0]?.message);
851
+ const allErrorCodes = {};
852
+ for (const issue of parsedResult.error.issues) {
853
+ const code = issue.code.toUpperCase();
854
+ allErrorCodes[code] = (allErrorCodes[code] ?? 0) + 1;
855
+ }
856
+ throw new DataError_default(data, Object.entries(allErrorCodes).toSorted(([_, firstCount], [__, secondCount]) => {
857
+ return secondCount - firstCount;
858
+ }).map(([code, count], _, allErrorCodes$1) => {
859
+ return allErrorCodes$1.length === 1 && count === 1 ? code : `${code}×${count}`;
860
+ }).join(","), `\n\n${z$1.prettifyError(parsedResult.error)}\n`);
852
861
  }
853
862
  return parsedResult.data;
854
863
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alextheman/utility",
3
- "version": "4.7.0",
3
+ "version": "4.8.0",
4
4
  "description": "Helpful utility functions.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,7 +25,7 @@
25
25
  "@types/libsodium-wrappers": "^0.7.14",
26
26
  "@types/node": "^25.0.9",
27
27
  "@typescript-eslint/types": "^8.53.0",
28
- "alex-c-line": "^1.17.3",
28
+ "alex-c-line": "^1.18.4",
29
29
  "dotenv-cli": "^11.0.0",
30
30
  "eslint": "^9.39.2",
31
31
  "globals": "^17.0.0",