mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-09 23:12:06 -03:30
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:
parent
3a17b0a480
commit
e98651b395
@ -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(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user