





















@@ -317,6 +317,31 @@ function collectAllowedValuesFromCustomIssue(record: UnknownIssueRecord): Allowe
317317return collectAllowedValuesFromBundledChannelSchemaPath(toConfigPathSegments(record.path));
318318}
319319320+function appendNumericBoundHint(message: string, record: UnknownIssueRecord): string {
321+const origin = typeof record.origin === "string" ? record.origin : "";
322+if (origin !== "number") {
323+return message;
324+}
325+const inclusive = record.inclusive === true;
326+if (record.code === "too_big") {
327+const maximum = typeof record.maximum === "number" ? record.maximum : undefined;
328+if (maximum !== undefined) {
329+return inclusive
330+ ? `${message} (maximum: ${maximum})`
331+ : `${message} (must be less than ${maximum})`;
332+}
333+}
334+if (record.code === "too_small") {
335+const minimum = typeof record.minimum === "number" ? record.minimum : undefined;
336+if (minimum !== undefined) {
337+return inclusive
338+ ? `${message} (minimum: ${minimum})`
339+ : `${message} (must be greater than ${minimum})`;
340+}
341+}
342+return message;
343+}
344+320345function collectAllowedValuesFromIssue(issue: unknown): AllowedValuesCollection {
321346const record = toIssueRecord(issue);
322347if (!record) {
@@ -581,6 +606,11 @@ function mapZodIssueToConfigIssue(issue: unknown): ConfigValidationIssue {
581606const path = formatConfigPath(toConfigPathSegments(record?.path));
582607const message = typeof record?.message === "string" ? record.message : "Invalid input";
583608609+// Numeric ceiling/floor hints (too_big / too_small with numeric origin).
610+// Append a parenthesized bound alongside Zod's native message,
611+// matching the clarity that enum/union rejections get via (allowed: …).
612+const enrichedMessage = record ? appendNumericBoundHint(message, record) : message;
613+584614const allowedValuesSummary = summarizeAllowedValues(collectAllowedValuesFromUnknownIssue(issue));
585615586616// Bindings use a plain union because legacy route bindings may omit `type`.
@@ -599,12 +629,12 @@ function mapZodIssueToConfigIssue(issue: unknown): ConfigValidationIssue {
599629}
600630601631if (!allowedValuesSummary) {
602-return { path, message };
632+return { path, message: enrichedMessage };
603633}
604634605635return {
606636 path,
607-message: appendAllowedValuesHint(message, allowedValuesSummary),
637+message: appendAllowedValuesHint(enrichedMessage, allowedValuesSummary),
608638allowedValues: allowedValuesSummary.values,
609639allowedValuesHiddenCount: allowedValuesSummary.hiddenCount,
610640};
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。