@@ -27,6 +27,7 @@ import { useUser } from "~/hooks/useUser";
2727import { redirectWithSuccessMessage } from "~/models/message.server" ;
2828import { updateUser } from "~/models/user.server" ;
2929import { requireUserId } from "~/services/session.server" ;
30+ import { emailSchema , MAX_EMAIL_LENGTH } from "~/utils/emailValidation" ;
3031import { rootPath } from "~/utils/pathBuilder" ;
3132import { getVercelInstallParams } from "~/v3/vercel" ;
3233
@@ -72,10 +73,8 @@ function createSchema(
7273 return z
7374 . object ( {
7475 name : z . string ( ) . min ( 3 , "Your name must be at least 3 characters" ) . max ( 50 ) ,
75- email : z
76- . string ( )
77- . email ( )
78- . superRefine ( ( email , ctx ) => {
76+ email : emailSchema . pipe (
77+ z . string ( ) . superRefine ( ( email , ctx ) => {
7978 if ( constraints . isEmailUnique === undefined ) {
8079 ctx . addIssue ( {
8180 code : z . ZodIssueCode . custom ,
@@ -93,8 +92,9 @@ function createSchema(
9392 } ) ;
9493 } ) ;
9594 }
96- } ) ,
97- confirmEmail : z . string ( ) ,
95+ } )
96+ ) ,
97+ confirmEmail : emailSchema ,
9898 referralSource : z . string ( ) . optional ( ) ,
9999 referralSourceOther : z . string ( ) . optional ( ) ,
100100 role : z . string ( ) . optional ( ) ,
@@ -290,6 +290,7 @@ export default function Page() {
290290 </ Label >
291291 < Input
292292 { ...getInputProps ( email , { type : "email" } ) }
293+ maxLength = { MAX_EMAIL_LENGTH }
293294 defaultValue = { enteredEmail }
294295 onChange = { ( e ) => {
295296 setEnteredEmail ( e . target . value ) ;
@@ -306,6 +307,7 @@ export default function Page() {
306307 < Label htmlFor = { confirmEmail . id } > Confirm email</ Label >
307308 < Input
308309 { ...getInputProps ( confirmEmail , { type : "email" } ) }
310+ maxLength = { MAX_EMAIL_LENGTH }
309311 placeholder = "Your email, again"
310312 icon = { EnvelopeIcon }
311313 spellCheck = { false }
0 commit comments