File tree 2 files changed +5
-4
lines changed
2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ export enum PrimaryInputNames {
22
22
const passwordRgx : RegExp = / ^ (? = .* [ a - z ] ) (? = .* [ A - Z ] ) (? = .* \d ) (? = .* [ ^ a - z A - Z \d \s ] ) .{ 8 , } $ /
23
23
const nameRgx : RegExp = new RegExp ( "^[' -]*[a-z]+[a-z' -]+$" , "i" )
24
24
const anyString : RegExp = new RegExp ( "[sS]*" )
25
+ const phoneNumberRgx : RegExp = / ^ [ \+ ] ? [ ( ] ? [ 0 - 9 ] { 3 } [ ) ] ? [ - \s \. ] ? [ 0 - 9 ] { 3 } [ - \s \. ] ? [ 0 - 9 ] { 4 , 6 } $ /
25
26
26
27
export const primaryInputValidation = {
27
28
[ PrimaryInputNames . BADGE_NUMBER ] : {
@@ -81,8 +82,8 @@ export const primaryInputValidation = {
81
82
inputType : "text"
82
83
} ,
83
84
[ PrimaryInputNames . PHONE_NUMBER ] : {
84
- errorMessage : 'A phone number is required, formatted as "123 456 7890"' ,
85
- pattern : / \d { 3 } \d { 3 } \d { 4 } / ,
85
+ errorMessage : "A valid phone number is required" ,
86
+ pattern : phoneNumberRgx ,
86
87
inputType : "tel"
87
88
} ,
88
89
[ PrimaryInputNames . LOGIN_PASSWORD ] : {
Original file line number Diff line number Diff line change @@ -46,10 +46,10 @@ describe("behaviors", () => {
46
46
}
47
47
} )
48
48
49
- it ( "checks phone formatting " , async ( ) => {
49
+ it ( "checks phone number length " , async ( ) => {
50
50
const r = renderPage ( )
51
51
act ( ( ) => {
52
- userEvent . type ( r . phoneNumber , "5555555555 " )
52
+ userEvent . type ( r . phoneNumber , "5555555555555 " )
53
53
userEvent . click ( r . submit )
54
54
} )
55
55
await expect ( r . findByText ( / p h o n e n u m b e r i s r e q u i r e d / ) ) . resolves . toBeInTheDocument ( )
You can’t perform that action at this time.
0 commit comments