fix: validate AI agent request text correctly
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import 'reflect-metadata';
|
||||
|
||||
import { validate } from 'class-validator';
|
||||
|
||||
import { CreateAgentPlanDto } from './create-agent-plan.dto';
|
||||
|
||||
describe('CreateAgentPlanDto', () => {
|
||||
const createDto = (request: string): CreateAgentPlanDto => Object.assign(new CreateAgentPlanDto(), {
|
||||
courseId: '019f3689-4fe2-7b93-a7c4-72e51fe3ec17',
|
||||
week: 1,
|
||||
request,
|
||||
modules: [],
|
||||
});
|
||||
|
||||
it('accepts a non-empty agent request', async () => {
|
||||
const errors = await validate(createDto('지금 모듈 몇 개야?'));
|
||||
|
||||
expect(errors).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('rejects an empty agent request', async () => {
|
||||
const errors = await validate(createDto(''));
|
||||
|
||||
expect(errors.some((error) => error.property === 'request')).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Type } from 'class-transformer';
|
||||
import { ArrayMaxSize, IsArray, IsInt, IsOptional, IsString, IsUUID, Max, MaxLength, Min, ValidateNested } from 'class-validator';
|
||||
import { ArrayMaxSize, IsArray, IsInt, IsOptional, IsString, IsUUID, Max, MaxLength, Min, MinLength, ValidateNested } from 'class-validator';
|
||||
|
||||
class AgentWorkspaceFileDto {
|
||||
@IsString()
|
||||
@@ -39,7 +39,7 @@ export class CreateAgentPlanDto {
|
||||
week?: number;
|
||||
|
||||
@IsString()
|
||||
@Min(1)
|
||||
@MinLength(1)
|
||||
@MaxLength(4000)
|
||||
request: string;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user