diff --git a/ui/app/mirrors/create/handlers.ts b/ui/app/mirrors/create/handlers.ts index 4338df727c..35ccb142cc 100644 --- a/ui/app/mirrors/create/handlers.ts +++ b/ui/app/mirrors/create/handlers.ts @@ -41,8 +41,7 @@ const CDCCheck = ( ) => { const flowNameValid = flowNameSchema.safeParse(flowJobName); if (!flowNameValid.success) { - const flowNameErr = flowNameValid.error.issues[0].message; - return flowNameErr; + return flowNameValid.error.issues[0].message; } const tableNameMapping = reformattedTableMapping(rows); @@ -81,17 +80,16 @@ const validateCDCFields = ( )[], config: CDCConfig ): string | undefined => { - let validationErr: string | undefined; const tablesValidity = tableMappingSchema.safeParse(tableMapping); if (!tablesValidity.success) { - validationErr = tablesValidity.error.issues[0].message; + return tablesValidity.error.issues[0].message; } + console.log(config); const configValidity = cdcSchema.safeParse(config); if (!configValidity.success) { - validationErr = configValidity.error.issues[0].message; + return configValidity.error.issues[0].message; } - return validationErr; }; const validateQRepFields = ( @@ -101,12 +99,10 @@ const validateQRepFields = ( if (query.length < 5) { return 'Query is invalid'; } - let validationErr: string | undefined; const configValidity = qrepSchema.safeParse(config); if (!configValidity.success) { - validationErr = configValidity.error.issues[0].message; + return configValidity.error.issues[0].message; } - return validationErr; }; interface TableMapping { @@ -148,7 +144,7 @@ export const handleCreateCDC = async ( route: RouteCallback ) => { const err = CDCCheck(flowJobName, rows, config, destinationType); - if (err != '') { + if (err) { notifyErr(err); return; } @@ -411,7 +407,7 @@ export const handleValidateCDC = async ( ) => { setLoading(true); const err = CDCCheck(flowJobName, rows, config, destinationType); - if (err != '') { + if (err) { notifyErr(err); setLoading(false); return; diff --git a/ui/app/mirrors/create/schema.ts b/ui/app/mirrors/create/schema.ts index c182c64a99..04b5f94659 100644 --- a/ui/app/mirrors/create/schema.ts +++ b/ui/app/mirrors/create/schema.ts @@ -47,13 +47,13 @@ export const cdcSchema = z.object({ .string({ invalid_type_error: 'Publication name must be a string', }) - .max(255, 'Publication name must be less than 255 characters') + .max(255, 'Publication name must be less than 256 characters') .optional(), replicationSlotName: z .string({ invalid_type_error: 'Replication slot name must be a string', }) - .max(255, 'Replication slot name must be less than 255 characters') + .max(255, 'Replication slot name must be less than 256 characters') .optional(), snapshotNumRowsPerPartition: z .number({ @@ -80,13 +80,13 @@ export const cdcSchema = z.object({ .string({ invalid_type_error: 'Snapshot staging path must be a string', }) - .max(255, 'Snapshot staging path must be less than 255 characters') + .max(255, 'Snapshot staging path must be less than 256 characters') .optional(), cdcStagingPath: z .string({ invalid_type_error: 'CDC staging path must be a string', }) - .max(255, 'CDC staging path must be less than 255 characters') + .max(255, 'CDC staging path must be less than 256 characters') .optional(), softDelete: z.boolean().optional(), }); @@ -104,21 +104,21 @@ export const qrepSchema = z.object({ required_error: 'Destination table name is required', }) .min(1, 'Destination table name must be non-empty') - .max(255, 'Destination table name must be less than 255 characters'), + .max(255, 'Destination table name must be less than 256 characters'), watermarkTable: z .string({ invalid_type_error: 'Watermark table must be a string', required_error: 'Watermark table is required', }) .min(1, 'Watermark table must be non-empty') - .max(255, 'Watermark table must be less than 255 characters'), + .max(255, 'Watermark table must be less than 256 characters'), watermarkColumn: z .string({ invalid_type_error: 'Watermark column must be a string', required_error: 'Watermark column is required', }) .min(1, 'Watermark column must be non-empty') - .max(255, 'Watermark column must be less than 255 characters'), + .max(255, 'Watermark column must be less than 256 characters'), numRowsPerPartition: z .number({ invalid_type_error: 'Rows per partition must be a number', @@ -137,7 +137,7 @@ export const qrepSchema = z.object({ .string({ invalid_type_error: 'Staging path must be a string', }) - .max(255, 'Staging path must be less than 255 characters') + .max(255, 'Staging path must be less than 256 characters') .optional(), writeMode: z.object( {