Show length validations in the admin UI

Closes #42178

Signed-off-by: Alexander Schwartz <aschwart@redhat.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@gmx.net>
Co-authored-by: Jon Koops <jonkoops@gmail.com>
This commit is contained in:
Alexander Schwartz 2025-09-04 17:28:33 +02:00 committed by GitHub
parent 3a17b0a480
commit e98651b395
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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<T>(
).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(