43 lines
931 B
TypeScript
43 lines
931 B
TypeScript
import { IsNumber, IsString, IsOptional, IsUUID, ValidateNested, IsArray, IsDateString } from 'class-validator';
|
|
import { Type } from 'class-transformer';
|
|
import { BaseDto } from '../../_core/dto/base.dto';
|
|
|
|
// DTO for Options (remains the same as it's validation-focused)
|
|
class CreateOptionsDto {
|
|
@IsString()
|
|
value: string;
|
|
|
|
@IsNumber()
|
|
count: number;
|
|
}
|
|
|
|
// DTO for Opinion (remains the same)
|
|
class CreateOpinionDto {
|
|
@ValidateNested()
|
|
@Type(() => CreateOptionsDto)
|
|
options: CreateOptionsDto;
|
|
|
|
@IsUUID()
|
|
questionId: string;
|
|
}
|
|
|
|
// Main DTO for creating a FormResult (remains largely the same)
|
|
export class CreateFormResultDto extends BaseDto {
|
|
@IsNumber()
|
|
numParticipants: number;
|
|
|
|
@IsNumber()
|
|
numQuestions: number;
|
|
|
|
@IsNumber()
|
|
numAnswers: number;
|
|
|
|
@IsNumber()
|
|
numComplete: number;
|
|
|
|
@IsArray()
|
|
@ValidateNested({ each: true })
|
|
@Type(() => CreateOpinionDto)
|
|
opinions: CreateOpinionDto[];
|
|
}
|