File
|
course_module_id
|
Type : number | null
|
Decorators :
@Expose() @IsOptional() @Transform( => ) @ValidateIf(o => ) @IsInt()
|
|
|
|
question_text
|
Type : string
|
Decorators :
@Expose() @IsOptional() @IsString()
|
|
|
|
sort_order
|
Type : number
|
Decorators :
@Expose() @IsOptional() @IsNumber() @Transform( => )
|
|
|
import { Exclude, Expose, Transform } from "class-transformer";
import { IsInt, IsNumber, IsOptional, IsString, ValidateIf } from "class-validator";
@Exclude()
export class AssessmentQuestionSaveDto {
@Expose()
@IsOptional()
@IsString()
question_text!: string;
@Expose()
@IsOptional()
@Transform(({ value }) =>
value === "" || value === undefined ? undefined : value === null ? null : Number(value),
)
@ValidateIf((o) => o.course_module_id !== null && o.course_module_id !== undefined)
@IsInt()
course_module_id!: number | null;
@Expose()
@IsOptional()
@IsNumber()
// Keep undefined as undefined so partial updates don't overwrite to 0.
@Transform(({ value }) => (value == null || value === "" ? undefined : Number(value)))
sort_order!: number;
}