wip: disallow unknown fields

This commit is contained in:
Eugene Molodkin 2024-11-11 14:42:30 +01:00
parent d0b080f6e9
commit 5594ff45e1
No known key found for this signature in database
2 changed files with 14 additions and 15 deletions

View file

@ -1,13 +1,17 @@
import { z } from 'zod';
export const testDefinitionCreateRequestBodySchema = z.object({
name: z.string().min(1).max(255),
workflowId: z.string().min(1),
evaluationWorkflowId: z.string().min(1).optional(),
});
export const testDefinitionCreateRequestBodySchema = z
.object({
name: z.string().min(1).max(255),
workflowId: z.string().min(1),
evaluationWorkflowId: z.string().min(1).optional(),
})
.strict();
export const testDefinitionPatchRequestBodySchema = z.object({
name: z.string().min(1).max(255).optional(),
evaluationWorkflowId: z.string().min(1).optional(),
annotationTagId: z.string().min(1).optional(),
});
export const testDefinitionPatchRequestBodySchema = z
.object({
name: z.string().min(1).max(255).optional(),
evaluationWorkflowId: z.string().min(1).optional(),
annotationTagId: z.string().min(1).optional(),
})
.strict();

View file

@ -89,11 +89,6 @@ export class TestDefinitionService {
await validateEntity(updatedTest);
}
// Do not allow updating the workflow ID after test definition creation
if (attrs.workflowId) {
delete attrs.workflowId;
}
// Check if the annotation tag exists
if (attrs.annotationTagId) {
const annotationTagExists = await this.annotationTagRepository.exists({