@@ -5,9 +5,11 @@ import {
5
5
IsArray ,
6
6
IsBoolean ,
7
7
IsEnum ,
8
+ IsNotEmpty ,
8
9
IsNumber ,
9
10
IsOptional ,
10
11
IsString ,
12
+ Max ,
11
13
Min ,
12
14
ValidateNested ,
13
15
} from 'class-validator' ;
@@ -61,6 +63,7 @@ export class ScorecardQuestionBaseDto {
61
63
example : 'What is the challenge?' ,
62
64
} )
63
65
@IsString ( )
66
+ @IsNotEmpty ( )
64
67
description : string ;
65
68
66
69
@ApiProperty ( {
@@ -72,6 +75,8 @@ export class ScorecardQuestionBaseDto {
72
75
73
76
@ApiProperty ( { description : 'The weight of the question' , example : 10 } )
74
77
@IsNumber ( )
78
+ @Min ( 0 )
79
+ @Max ( 100 )
75
80
weight : number ;
76
81
77
82
@ApiProperty ( {
@@ -119,10 +124,13 @@ export class ScorecardSectionBaseDto {
119
124
example : 'Technical Skills' ,
120
125
} )
121
126
@IsString ( )
127
+ @IsNotEmpty ( )
122
128
name : string ;
123
129
124
130
@ApiProperty ( { description : 'The weight of the section' , example : 20 } )
125
131
@IsNumber ( )
132
+ @Min ( 0 )
133
+ @Max ( 100 )
126
134
weight : number ;
127
135
128
136
@ApiProperty ( { description : 'Sort order of the section' , example : 1 } )
@@ -162,10 +170,13 @@ export class ScorecardGroupBaseDto {
162
170
163
171
@ApiProperty ( { description : 'The name of the group' , example : 'Group A' } )
164
172
@IsString ( )
173
+ @IsNotEmpty ( )
165
174
name : string ;
166
175
167
176
@ApiProperty ( { description : 'The weight of the group' , example : 30 } )
168
177
@IsNumber ( )
178
+ @Min ( 0 )
179
+ @Max ( 100 )
169
180
weight : number ;
170
181
171
182
@ApiProperty ( { description : 'Sort order of the group' , example : 1 } )
@@ -241,6 +252,7 @@ export class ScorecardBaseDto {
241
252
242
253
@ApiProperty ( { description : 'The maximum score' , example : 100 } )
243
254
@IsNumber ( )
255
+ @Max ( 100 )
244
256
@IsGreaterThan ( 'minScore' )
245
257
maxScore : number ;
246
258
@@ -330,18 +342,22 @@ export function mapScorecardRequestForCreate(request: ScorecardRequestDto) {
330
342
331
343
return {
332
344
...request ,
345
+ id : undefined ,
333
346
...userFields ,
334
347
scorecardGroups : {
335
348
create : request . scorecardGroups . map ( ( group ) => ( {
336
349
...group ,
350
+ id : undefined ,
337
351
...userFields ,
338
352
sections : {
339
353
create : group . sections . map ( ( section ) => ( {
340
354
...section ,
355
+ id : undefined ,
341
356
...userFields ,
342
357
questions : {
343
358
create : section . questions . map ( ( question ) => ( {
344
359
...question ,
360
+ id : undefined ,
345
361
sortOrder : 1 ,
346
362
...userFields ,
347
363
} ) ) ,
0 commit comments