From e98651b395516c23f0d2b36a04b4dd4595e87cf7 Mon Sep 17 00:00:00 2001 From: Alexander Schwartz Date: Thu, 4 Sep 2025 17:28:33 +0200 Subject: [PATCH] Show length validations in the admin UI Closes #42178 Signed-off-by: Alexander Schwartz Signed-off-by: Alexander Schwartz Co-authored-by: Jon Koops --- js/libs/ui-shared/src/user-profile/utils.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/js/libs/ui-shared/src/user-profile/utils.ts b/js/libs/ui-shared/src/user-profile/utils.ts index 7aa6b8c69a6..39106733a41 100644 --- a/js/libs/ui-shared/src/user-profile/utils.ts +++ b/js/libs/ui-shared/src/user-profile/utils.ts @@ -15,7 +15,7 @@ export type UserFormFields = Omit< type FieldError = { field: string; errorMessage: string; - params?: string[]; + params?: unknown[]; }; type ErrorArray = { errors?: FieldError[] }; @@ -24,7 +24,11 @@ export type UserProfileError = { responseData: ErrorArray | FieldError; }; -const isBundleKey = (displayName?: string) => displayName?.includes("${"); +const isBundleKey = (displayName: unknown) => { + return displayName && typeof displayName === "string" + ? displayName.includes("${") + : false; +}; const unWrap = (key: string) => key.substring(2, key.length - 1); export const label = ( @@ -73,7 +77,9 @@ export function setUserProfileServerError( ).forEach((e) => { const params = Object.assign( {}, - e.params?.map((p) => (isBundleKey(p?.toString()) ? t(unWrap(p)) : p)), + e.params?.map((p) => + isBundleKey(p?.toString()) ? t(unWrap(p as string)) : p, + ), ); setError(fieldName(e.field) as keyof T, { message: t(