From 3e708255a7dcf33c8607d8d341db3e5ab5e4e7aa Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Sun, 1 Feb 2026 12:44:05 -0600 Subject: [PATCH] clean up error messages --- web/src/lib/config-schema/errorMessages.ts | 65 ---------------------- web/src/lib/config-schema/index.ts | 2 - 2 files changed, 67 deletions(-) diff --git a/web/src/lib/config-schema/errorMessages.ts b/web/src/lib/config-schema/errorMessages.ts index 6eae3643c..ecbe41020 100644 --- a/web/src/lib/config-schema/errorMessages.ts +++ b/web/src/lib/config-schema/errorMessages.ts @@ -4,49 +4,6 @@ import type { ErrorTransformer } from "@rjsf/utils"; import type { i18n as I18n } from "i18next"; -export interface ErrorMessageMap { - [keyword: string]: string | ((params: Record) => string); -} - -// Default error messages for common validation keywords -export const defaultErrorMessages: ErrorMessageMap = { - required: "This field is required", - type: (params) => { - const expectedType = params.type as string; - return `Expected ${expectedType} value`; - }, - minimum: (params) => `Must be at least ${params.limit}`, - maximum: (params) => `Must be at most ${params.limit}`, - minLength: (params) => `Must be at least ${params.limit} characters`, - maxLength: (params) => `Must be at most ${params.limit} characters`, - pattern: "Invalid format", - format: (params) => { - const format = params.format as string; - const formatLabels: Record = { - email: "Invalid email address", - uri: "Invalid URL", - "date-time": "Invalid date/time format", - ipv4: "Invalid IP address", - ipv6: "Invalid IPv6 address", - }; - return formatLabels[format] || `Invalid ${format} format`; - }, - enum: (params) => { - const allowedValues = params.allowedValues as unknown; - if (Array.isArray(allowedValues)) { - return `Must be one of: ${allowedValues.join(", ")}`; - } - return "Must be one of the allowed values"; - }, - const: "Value does not match expected constant", - uniqueItems: "All items must be unique", - minItems: (params) => `Must have at least ${params.limit} items`, - maxItems: (params) => `Must have at most ${params.limit} items`, - additionalProperties: "Unknown property is not allowed", - oneOf: "Must match exactly one of the allowed schemas", - anyOf: "Must match at least one of the allowed schemas", -}; - /** * Creates an error transformer function for RJSF * Transforms technical JSON Schema errors into user-friendly messages @@ -54,23 +11,6 @@ export const defaultErrorMessages: ErrorMessageMap = { export function createErrorTransformer(i18n: I18n): ErrorTransformer { const t = i18n.t.bind(i18n); - const getDefaultMessage = ( - errorType: string, - params: Record, - ): string | undefined => { - const template = defaultErrorMessages[errorType]; - - if (!template) { - return undefined; - } - - if (typeof template === "function") { - return template(params); - } - - return template; - }; - const normalizeParams = ( params: Record | undefined, ): Record => { @@ -138,11 +78,6 @@ export function createErrorTransformer(i18n: I18n): ErrorTransformer { } } - // Fall back to English defaults - if (!message) { - message = getDefaultMessage(errorType, normalizedParams); - } - if (!message) { return error; } diff --git a/web/src/lib/config-schema/index.ts b/web/src/lib/config-schema/index.ts index 09cb20829..5e6523f30 100644 --- a/web/src/lib/config-schema/index.ts +++ b/web/src/lib/config-schema/index.ts @@ -14,6 +14,4 @@ export { createErrorTransformer, transformPydanticErrors, extractFieldPath, - defaultErrorMessages, } from "./errorMessages"; -export type { ErrorMessageMap } from "./errorMessages";