This repository was archived by the owner on Nov 19, 2024. It is now read-only.
File tree 4 files changed +24
-12
lines changed
4 files changed +24
-12
lines changed Original file line number Diff line number Diff line change 1
1
export type User = {
2
2
id : string ;
3
3
email : string ;
4
- passcode : string ;
4
+ passcode : number ;
5
5
name : string ;
6
6
} ;
7
7
@@ -16,19 +16,19 @@ export const database: { users: User[]; posts: Post[] } = {
16
16
{
17
17
id : '3dcb4a1f-0c91-42c5-834f-26d227c532e2' ,
18
18
19
- passcode : ' 1234' ,
19
+ passcode : 1234 ,
20
20
name : 'James' ,
21
21
} ,
22
22
{
23
23
id : 'ea120573-2eb4-495e-be48-1b2debac2640' ,
24
24
25
- passcode : ' 9876' ,
25
+ passcode : 9876 ,
26
26
name : 'Alex' ,
27
27
} ,
28
28
{
29
29
id : '2ee1c07c-7537-48f5-b5d8-8740e165cd62' ,
30
30
31
- passcode : '1234' ,
31
+ passcode : 5678 ,
32
32
name : 'Sachin' ,
33
33
} ,
34
34
] ,
Original file line number Diff line number Diff line change @@ -69,7 +69,10 @@ const authRouter = createRouter()
69
69
} ,
70
70
input : z . object ( {
71
71
email : z . string ( ) . email ( ) ,
72
- passcode : z . string ( ) . regex ( / ^ [ 0 - 9 ] { 4 } $ / ) ,
72
+ passcode : z . preprocess (
73
+ ( arg ) => ( typeof arg === 'string' ? parseInt ( arg ) : arg ) ,
74
+ z . number ( ) . min ( 1000 ) . max ( 9999 ) ,
75
+ ) ,
73
76
name : z . string ( ) . min ( 3 ) ,
74
77
} ) ,
75
78
output : z . object ( {
@@ -113,7 +116,10 @@ const authRouter = createRouter()
113
116
} ,
114
117
input : z . object ( {
115
118
email : z . string ( ) . email ( ) ,
116
- passcode : z . string ( ) . regex ( / ^ [ 0 - 9 ] { 4 } $ / ) ,
119
+ passcode : z . preprocess (
120
+ ( arg ) => ( typeof arg === 'string' ? parseInt ( arg ) : arg ) ,
121
+ z . number ( ) . min ( 1000 ) . max ( 9999 ) ,
122
+ ) ,
117
123
} ) ,
118
124
output : z . object ( {
119
125
token : z . string ( ) ,
Original file line number Diff line number Diff line change 1
1
export type User = {
2
2
id : string ;
3
3
email : string ;
4
- passcode : string ;
4
+ passcode : number ;
5
5
name : string ;
6
6
} ;
7
7
@@ -16,19 +16,19 @@ export const database: { users: User[]; posts: Post[] } = {
16
16
{
17
17
id : '3dcb4a1f-0c91-42c5-834f-26d227c532e2' ,
18
18
19
- passcode : ' 1234' ,
19
+ passcode : 1234 ,
20
20
name : 'James' ,
21
21
} ,
22
22
{
23
23
id : 'ea120573-2eb4-495e-be48-1b2debac2640' ,
24
24
25
- passcode : ' 9876' ,
25
+ passcode : 9876 ,
26
26
name : 'Alex' ,
27
27
} ,
28
28
{
29
29
id : '2ee1c07c-7537-48f5-b5d8-8740e165cd62' ,
30
30
31
- passcode : '1234' ,
31
+ passcode : 5678 ,
32
32
name : 'Sachin' ,
33
33
} ,
34
34
] ,
Original file line number Diff line number Diff line change @@ -66,7 +66,10 @@ const authRouter = createRouter()
66
66
} ,
67
67
input : z . object ( {
68
68
email : z . string ( ) . email ( ) ,
69
- passcode : z . string ( ) . regex ( / ^ [ 0 - 9 ] { 4 } $ / ) ,
69
+ passcode : z . preprocess (
70
+ ( arg ) => ( typeof arg === 'string' ? parseInt ( arg ) : arg ) ,
71
+ z . number ( ) . min ( 1000 ) . max ( 9999 ) ,
72
+ ) ,
70
73
name : z . string ( ) . min ( 3 ) ,
71
74
} ) ,
72
75
output : z . object ( {
@@ -110,7 +113,10 @@ const authRouter = createRouter()
110
113
} ,
111
114
input : z . object ( {
112
115
email : z . string ( ) . email ( ) ,
113
- passcode : z . string ( ) . regex ( / ^ [ 0 - 9 ] { 4 } $ / ) ,
116
+ passcode : z . preprocess (
117
+ ( arg ) => ( typeof arg === 'string' ? parseInt ( arg ) : arg ) ,
118
+ z . number ( ) . min ( 1000 ) . max ( 9999 ) ,
119
+ ) ,
114
120
} ) ,
115
121
output : z . object ( {
116
122
token : z . string ( ) ,
You can’t perform that action at this time.
0 commit comments