import { IsString, IsDateString, IsJSON, IsNotEmpty, Length, IsArray, Validate, } from 'class-validator'; import { ArrayLength } from 'src/shared/array-validation'; export class GameDTO { // uses class-validator built in validations // see https://github.com/typestack/class-validator @IsString() @IsNotEmpty() @Length(2, 31) name: string; @IsString() @IsNotEmpty() @Length(1, 255) desc: string; center: JSON; //@IsJSON() // doesn't accept with IsJSON, WIP to get validation for map map?: JSON; @IsDateString() @IsNotEmpty() startdate: string; @IsDateString() @IsNotEmpty() enddate: string; @IsArray() @IsNotEmpty() @Length(5, 15, { each: true, }) // custom validation for array length (arr>min, arr<max) //@Validate(ArrayLength, [4, 8]) passwords: string[]; factions: FactionDTO[]; } export class FactionDTO { @IsString() @IsNotEmpty() @Length(2, 15) name: string; id: string; game: GameDTO; }