This commit is contained in:
Dmitry 2026-01-06 23:36:05 +03:00
parent b0b49d1456
commit f59f214189
2 changed files with 23 additions and 3 deletions

View file

@ -7,7 +7,6 @@ generator client {
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {

View file

@ -1,4 +1,23 @@
import { IsString, IsBoolean, IsArray, IsOptional } from 'class-validator';
import { IsString, IsBoolean, IsArray, IsOptional, ValidateNested, IsNumber } from 'class-validator';
import { Type } from 'class-transformer';
class AnswerDto {
@IsString()
text: string;
@IsNumber()
points: number;
}
class QuestionDto {
@IsString()
question: string;
@IsArray()
@ValidateNested({ each: true })
@Type(() => AnswerDto)
answers: AnswerDto[];
}
export class UpdatePackDto {
@IsOptional()
@ -19,5 +38,7 @@ export class UpdatePackDto {
@IsOptional()
@IsArray()
questions?: Array<{ question: string; answer: string }>;
@ValidateNested({ each: true })
@Type(() => QuestionDto)
questions?: QuestionDto[];
}