@@ -120,15 +120,20 @@ export const rdsIntrospectBodySchema = rdsConnectionBodySchema.extend({
120120 engine : z . enum ( [ 'aurora-postgresql' , 'aurora-mysql' ] ) . optional ( ) ,
121121} )
122122
123- const mongoConnectionBodySchema = z . object ( {
124- host : z . string ( ) . min ( 1 , 'Host is required' ) ,
125- port : z . coerce . number ( ) . int ( ) . positive ( 'Port must be a positive integer' ) ,
126- database : z . string ( ) . min ( 1 , 'Database name is required' ) ,
127- username : z . string ( ) . min ( 1 , 'Username is required' ) . optional ( ) ,
128- password : z . string ( ) . min ( 1 , 'Password is required' ) . optional ( ) ,
129- authSource : z . string ( ) . optional ( ) ,
130- ssl : sslModeSchema ,
131- } )
123+ const mongoConnectionBodySchema = z
124+ . object ( {
125+ host : z . string ( ) . min ( 1 , 'Host is required' ) ,
126+ port : z . coerce . number ( ) . int ( ) . positive ( 'Port must be a positive integer' ) ,
127+ database : z . string ( ) . min ( 1 , 'Database name is required' ) ,
128+ username : z . string ( ) . min ( 1 , 'Username is required' ) . optional ( ) ,
129+ password : z . string ( ) . min ( 1 , 'Password is required' ) . optional ( ) ,
130+ authSource : z . string ( ) . optional ( ) ,
131+ ssl : sslModeSchema ,
132+ } )
133+ . refine ( ( data ) => Boolean ( data . username ) === Boolean ( data . password ) , {
134+ message : 'Username and password must be provided together' ,
135+ path : [ 'password' ] ,
136+ } )
132137
133138const mongoJsonStringOrObjectSchema = ( message : string ) =>
134139 z
0 commit comments