This repository was archived by the owner on Nov 19, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +24
-12
lines changed Expand file tree Collapse file tree 4 files changed +24
-12
lines changed Original file line number Diff line number Diff line change 11export type User = {
22 id : string ;
33 email : string ;
4- passcode : string ;
4+ passcode : number ;
55 name : string ;
66} ;
77
@@ -16,19 +16,19 @@ export const database: { users: User[]; posts: Post[] } = {
1616 {
1717 id : '3dcb4a1f-0c91-42c5-834f-26d227c532e2' ,
1818 email : 'jb@jamesbe.com' ,
19- passcode : ' 1234' ,
19+ passcode : 1234 ,
2020 name : 'James' ,
2121 } ,
2222 {
2323 id : 'ea120573-2eb4-495e-be48-1b2debac2640' ,
2424 email : 'alex@example.com' ,
25- passcode : ' 9876' ,
25+ passcode : 9876 ,
2626 name : 'Alex' ,
2727 } ,
2828 {
2929 id : '2ee1c07c-7537-48f5-b5d8-8740e165cd62' ,
3030 email : 'sachin@example.com' ,
31- passcode : '1234' ,
31+ passcode : 5678 ,
3232 name : 'Sachin' ,
3333 } ,
3434 ] ,
Original file line number Diff line number Diff line change @@ -69,7 +69,10 @@ const authRouter = createRouter()
6969 } ,
7070 input : z . object ( {
7171 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+ ) ,
7376 name : z . string ( ) . min ( 3 ) ,
7477 } ) ,
7578 output : z . object ( {
@@ -113,7 +116,10 @@ const authRouter = createRouter()
113116 } ,
114117 input : z . object ( {
115118 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+ ) ,
117123 } ) ,
118124 output : z . object ( {
119125 token : z . string ( ) ,
Original file line number Diff line number Diff line change 11export type User = {
22 id : string ;
33 email : string ;
4- passcode : string ;
4+ passcode : number ;
55 name : string ;
66} ;
77
@@ -16,19 +16,19 @@ export const database: { users: User[]; posts: Post[] } = {
1616 {
1717 id : '3dcb4a1f-0c91-42c5-834f-26d227c532e2' ,
1818 email : 'jb@jamesbe.com' ,
19- passcode : ' 1234' ,
19+ passcode : 1234 ,
2020 name : 'James' ,
2121 } ,
2222 {
2323 id : 'ea120573-2eb4-495e-be48-1b2debac2640' ,
2424 email : 'alex@example.com' ,
25- passcode : ' 9876' ,
25+ passcode : 9876 ,
2626 name : 'Alex' ,
2727 } ,
2828 {
2929 id : '2ee1c07c-7537-48f5-b5d8-8740e165cd62' ,
3030 email : 'sachin@example.com' ,
31- passcode : '1234' ,
31+ passcode : 5678 ,
3232 name : 'Sachin' ,
3333 } ,
3434 ] ,
Original file line number Diff line number Diff line change @@ -66,7 +66,10 @@ const authRouter = createRouter()
6666 } ,
6767 input : z . object ( {
6868 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+ ) ,
7073 name : z . string ( ) . min ( 3 ) ,
7174 } ) ,
7275 output : z . object ( {
@@ -110,7 +113,10 @@ const authRouter = createRouter()
110113 } ,
111114 input : z . object ( {
112115 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+ ) ,
114120 } ) ,
115121 output : z . object ( {
116122 token : z . string ( ) ,
You can’t perform that action at this time.
0 commit comments