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

json validation for node_settings

parent 08f59052
No related branches found
No related tags found
3 merge requests!59Development to master,!31Development,!29Json validation
...@@ -14,7 +14,7 @@ import { ...@@ -14,7 +14,7 @@ import {
import { ObjectivePointEntity } from './game.entity'; import { ObjectivePointEntity } from './game.entity';
import { CenterJSON } from '../shared/custom-validation'; import { CenterJSON } from '../shared/custom-validation';
import { FactionDTO } from '../faction/faction.dto'; import { FactionDTO } from '../faction/faction.dto';
import { CenterDTO } from './game.json.dto'; import { CenterDTO, NodeSettingsDTO } from './game.json.dto';
import { Type } from 'class-transformer'; import { Type } from 'class-transformer';
export class GameDTO { export class GameDTO {
...@@ -25,14 +25,15 @@ export class GameDTO { ...@@ -25,14 +25,15 @@ export class GameDTO {
@IsNotEmpty() @IsNotEmpty()
@Length(1, 255) @Length(1, 255)
desc: string; desc: string;
@IsNotEmpty()
@ValidateNested() @ValidateNested()
@Type(() => CenterDTO) @Type(() => CenterDTO)
center: CenterDTO; center: CenterDTO;
@Allow() @Allow()
map?: JSON; @ValidateNested()
@Type(() => NodeSettingsDTO)
nodesettings?: NodeSettingsDTO;
@Allow() @Allow()
nodesettings?: JSON; map?: JSON;
@IsDateString() @IsDateString()
@IsNotEmpty() @IsNotEmpty()
startdate: string; startdate: string;
......
...@@ -14,7 +14,7 @@ import { PersonEntity } from '../user/user.entity'; ...@@ -14,7 +14,7 @@ import { PersonEntity } from '../user/user.entity';
import { GameGroupEntity } from '../faction/faction.entity'; import { GameGroupEntity } from '../faction/faction.entity';
import { FactionEntity } from '../faction/faction.entity'; import { FactionEntity } from '../faction/faction.entity';
import { TaskEntity } from '../task/task.entity'; import { TaskEntity } from '../task/task.entity';
import { CenterDTO } from './game.json.dto'; import { CenterDTO, NodeSettingsDTO } from './game.json.dto';
// table that stores all created games // table that stores all created games
@Entity('Game') @Entity('Game')
...@@ -24,7 +24,7 @@ export class GameEntity { ...@@ -24,7 +24,7 @@ export class GameEntity {
@Column('text') desc: string; @Column('text') desc: string;
@Column('json') center: CenterDTO; @Column('json') center: CenterDTO;
@Column({ type: 'json', nullable: true }) map: JSON; @Column({ type: 'json', nullable: true }) map: JSON;
@Column({ type: 'json', nullable: true }) nodesettings?: JSON; @Column({ type: 'json', nullable: true }) nodesettings?: NodeSettingsDTO;
@Column('timestamp') startdate: Timestamp; @Column('timestamp') startdate: Timestamp;
@Column('timestamp') enddate: Timestamp; @Column('timestamp') enddate: Timestamp;
......
import { IsNumber } from 'class-validator';
export class NodeCoreSettingsDTO {
@IsNumber()
capture_time: number;
@IsNumber()
confirmation_time: number;
@IsNumber()
owner: number;
@IsNumber()
capture: number;
@IsNumber()
buttons_available: number;
@IsNumber()
heartbeat_interval: number;
}
import { GameDTO } from './game.dto'; import { IsNumber, ValidateNested } from 'class-validator';
import { IsNumber } from 'class-validator'; import { NodeCoreSettingsDTO } from './game.json-nested.dto';
import { Type } from 'class-transformer';
export class CenterDTO { export class CenterDTO {
@IsNumber() @IsNumber()
...@@ -7,3 +8,9 @@ export class CenterDTO { ...@@ -7,3 +8,9 @@ export class CenterDTO {
@IsNumber() @IsNumber()
lng: number; lng: number;
} }
export class NodeSettingsDTO {
@ValidateNested()
@Type(() => NodeCoreSettingsDTO)
node_settings: NodeCoreSettingsDTO;
}
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