From b5f16cfacf6cf1577f613d65a47b5894ffcd2ffb Mon Sep 17 00:00:00 2001 From: razbroc Date: Sun, 4 Jan 2026 14:43:34 +0200 Subject: [PATCH] refactor: enforce maximum length for product type in rasterProductTypeSchema --- src/schemas/core/job.schema.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/schemas/core/job.schema.ts b/src/schemas/core/job.schema.ts index a94fe67..fb94928 100644 --- a/src/schemas/core/job.schema.ts +++ b/src/schemas/core/job.schema.ts @@ -3,7 +3,11 @@ import { IJobResponse, OperationStatus } from '@map-colonies/mc-priority-queue'; import { INGESTION_VALIDATIONS, RASTER_DOMAIN, RasterProductTypes } from '../../constants'; import { createTaskResponseSchema } from './task.schema'; -export const rasterProductTypeSchema: ZodType = z.nativeEnum(RasterProductTypes); +// PostgreSQL table name limit: 63 chars (productID: 37 + separator: 1 + productType: 17 + suffix: 8) +const productTypeMaxLength = 17; +export const rasterProductTypeSchema: ZodType = z + .nativeEnum(RasterProductTypes) + .refine((productTypeValue) => productTypeValue.length <= productTypeMaxLength, { message: 'Product type must be at most 17 characters' }); export const resourceIdSchema = z .string() .regex(new RegExp(INGESTION_VALIDATIONS.productId.pattern), {