Skip to content
Snippets Groups Projects
Commit a9f76d3f authored by L4168's avatar L4168
Browse files

cleaning up dto

parent 727642cc
No related branches found
No related tags found
4 merge requests!59Development to master,!31Development,!26Piirto2,!25Dto service
import { import {
IsNotEmpty, IsNotEmpty,
IsString, IsString,
IsDate,
Length, Length,
IsInt,
Min,
Max,
IsArray,
IsJSON,
IsDateString, IsDateString,
IsNumber, IsNumber,
} from 'class-validator'; } from 'class-validator';
import { Timestamp } from 'typeorm';
import { ObjectivePointEntity } from './game.entity'; import { ObjectivePointEntity } from './game.entity';
export class GameDTO { export class GameDTO {
...@@ -23,11 +16,7 @@ export class GameDTO { ...@@ -23,11 +16,7 @@ export class GameDTO {
@Length(1, 255) @Length(1, 255)
desc: string; desc: string;
@IsNotEmpty() @IsNotEmpty()
//@IsJSON()
center: JSON; center: JSON;
//@IsJSON()
// doesn't accept with IsJSON, WIP to get validation for map and center
// IsJSON checks with json.parse, expecting string
map?: JSON; map?: JSON;
nodesettings?: JSON; nodesettings?: JSON;
@IsDateString() @IsDateString()
...@@ -36,12 +25,29 @@ export class GameDTO { ...@@ -36,12 +25,29 @@ export class GameDTO {
@IsDateString() @IsDateString()
@IsNotEmpty() @IsNotEmpty()
enddate: string; enddate: string;
// custom validation for array length (arr>min, arr<max)
//@Validate(ArrayLength, [4, 8])
factions?: FactionDTO[]; factions?: FactionDTO[];
objective_points?: FlagboxDTO[]; objective_points?: FlagboxDTO[];
} }
export class newGameDTO {
@IsString()
@IsNotEmpty()
@Length(3, 30)
name: string;
@IsString()
@IsNotEmpty()
@Length(1, 255)
desc: string;
@IsNotEmpty()
center: JSON;
@IsDateString()
@IsNotEmpty()
startdate: string;
@IsDateString()
@IsNotEmpty()
enddate: string;
}
export class FactionDTO { export class FactionDTO {
@IsString() @IsString()
@IsNotEmpty() @IsNotEmpty()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment