@@ -2,7 +2,7 @@ import { useClerk } from '@clerk/shared/react';
22import React , { useEffect , useMemo } from 'react' ;
33
44import { SignInContext , useCoreSignUp , useEnvironment , useOptions , useSignUpContext } from '../../contexts' ;
5- import { descriptors , Flex , Flow , localizationKeys } from '../../customizables' ;
5+ import { descriptors , Flex , Flow , localizationKeys , useLocalizations } from '../../customizables' ;
66import {
77 Card ,
88 Header ,
@@ -13,7 +13,7 @@ import {
1313import { useCardState } from '../../elements/contexts' ;
1414import { useRouter } from '../../router' ;
1515import type { FormControlState } from '../../utils' ;
16- import { buildRequest , handleError , useFormControl } from '../../utils' ;
16+ import { buildRequest , createUsernameError , handleError , useFormControl } from '../../utils' ;
1717import { SignUpForm } from './SignUpForm' ;
1818import type { ActiveIdentifier } from './signUpFormHelpers' ;
1919import {
@@ -30,7 +30,8 @@ function _SignUpContinue() {
3030 const clerk = useClerk ( ) ;
3131 const { navigate } = useRouter ( ) ;
3232 const { displayConfig, userSettings } = useEnvironment ( ) ;
33- const { attributes } = userSettings ;
33+ const { attributes, usernameSettings } = userSettings ;
34+ const { t, locale } = useLocalizations ( ) ;
3435 const { afterSignUpUrl, signInUrl, unsafeMetadata, initialValues = { } } = useSignUpContext ( ) ;
3536 const signUp = useCoreSignUp ( ) ;
3637 const options = useOptions ( ) ;
@@ -62,6 +63,8 @@ function _SignUpContinue() {
6263 type : 'text' ,
6364 label : localizationKeys ( 'formFieldLabel__username' ) ,
6465 placeholder : localizationKeys ( 'formFieldInputPlaceholder__username' ) ,
66+ transformer : value => value . trim ( ) ,
67+ buildErrorMessage : errors => createUsernameError ( errors , { t, locale, usernameSettings } ) ,
6568 } ) ,
6669 phoneNumber : useFormControl ( 'phoneNumber' , initialValues . phoneNumber || '' , {
6770 type : 'tel' ,
0 commit comments