checkpoint update on useFormValidation

This commit is contained in:
Joseph Garrone 2024-04-20 22:12:39 +02:00
parent f6bdd92f9e
commit f1a0887e9b

View File

@ -21,8 +21,8 @@ export function useFormValidation(params: {
passwordRequired?: boolean; passwordRequired?: boolean;
realm: { registrationEmailAsUsername: boolean }; realm: { registrationEmailAsUsername: boolean };
}; };
/** NOTE: Try to avoid passing a new ref every render for better performances. */
passwordValidators?: Validators; passwordValidators?: Validators;
//TODO: Add a param that enable not to use password confirmation
i18n: I18n; i18n: I18n;
}) { }) {
const { kcContext, passwordValidators = {}, i18n } = params; const { kcContext, passwordValidators = {}, i18n } = params;
@ -48,8 +48,10 @@ export function useFormValidation(params: {
"readOnly": false, "readOnly": false,
"validators": passwordValidators, "validators": passwordValidators,
"annotations": {}, "annotations": {},
"groupAnnotations": {}, "autocomplete": "new-password",
"autocomplete": "new-password" "html5DataAnnotations": {},
// NOTE: Compat with Keycloak version prior to 24
...({ "groupAnnotations": {} } as {})
}), }),
id<Attribute>({ id<Attribute>({
"name": "password-confirm", "name": "password-confirm",
@ -65,15 +67,17 @@ export function useFormValidation(params: {
} }
}, },
"annotations": {}, "annotations": {},
"groupAnnotations": {}, "html5DataAnnotations": {},
"autocomplete": "new-password" "autocomplete": "new-password",
// NOTE: Compat with Keycloak version prior to 24
...({ "groupAnnotations": {} } as {})
}) })
]) ])
], ],
[] []
); );
})(), })(),
[kcContext, passwordValidators] [kcContext, JSON.stringify(passwordValidators)]
); );
const { getErrors } = useGetErrors({ const { getErrors } = useGetErrors({