Skip to content

Commit f49b584

Browse files
authored
fix(profile): improve full name validation with clearer error messages (#1396)
1 parent 222d46d commit f49b584

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

  • web/sdk/react/components/organization/user

web/sdk/react/components/organization/user/update.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,20 @@ const generalSchema = yup
2525
.required('Name is required')
2626
.min(2, 'Name must be at least 2 characters')
2727
.matches(
28-
/^[a-zA-Z\s'-]+$/,
29-
'Name can only contain letters, spaces, hyphens, and apostrophes'
28+
/^[\p{L} .'-]+$/u,
29+
'Name can only contain letters, spaces, periods, hyphens, and apostrophes'
30+
)
31+
.matches(/^\p{L}/u, 'Name must start with a letter')
32+
.matches(
33+
/^\p{L}[\p{L} .'-]*\p{L}$|^\p{L}$/u,
34+
'Name must end with a letter'
35+
)
36+
.matches(/^(?!.* {2}).*$/, 'Name cannot have consecutive spaces')
37+
.matches(/^(?!.* [^\p{L}]).*$/u, 'Spaces must be followed by a letter')
38+
.matches(/^(?!.*-[^\p{L}]).*$/u, 'Hyphens must be followed by a letter')
39+
.matches(
40+
/^(?!.*'[^\p{L}]).*$/u,
41+
'Apostrophes must be followed by a letter'
3042
),
3143
email: yup.string().email().required()
3244
})

0 commit comments

Comments
 (0)