Skip to content

Commit

Permalink
fix password form validation
Browse files Browse the repository at this point in the history
  • Loading branch information
AyushAgrawal-A2 committed Jan 30, 2025
1 parent c77c11e commit 223dafe
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion quadratic-shared/typesAndSchemasConnections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,23 @@ export const ConnectionTypeDetailsPostgresSchema = z.object({
password: z.string().optional().transform(transformEmptyStringToUndefined),
});
export const ConnectionTypeDetailsMysqlSchema = ConnectionTypeDetailsPostgresSchema;
export const ConnectionTypeDetailsMssqlSchema = ConnectionTypeDetailsPostgresSchema.extend({
export const ConnectionTypeDetailsMssqlSchema = z.object({
host: z.string().min(1, { message: 'Required' }),
port: z
.string()
.min(1, { message: 'Required' })
.refine(
(port) => {
const portNumber = Number(port);
if (isNaN(portNumber)) return false;
return portNumber >= 0 && portNumber <= 65535;
},
{
message: 'Port must be a valid number between 0 and 65535',
}
),
database: z.string().optional(),
username: z.string().min(1, { message: 'Required' }),
password: z.string().min(1, { message: 'Required' }),
});
export const ConnectionTypeDetailsSnowflakeSchema = z.object({
Expand Down

0 comments on commit 223dafe

Please sign in to comment.