@@ -1,4 +1,5 @@
|
||||
import { IsInt, IsNotEmpty, IsOptional, IsPositive, IsString } from 'class-validator';
|
||||
import { TrackLapTimeCantBeNegativeError } from '../../errors/TrackErrors';
|
||||
import { Track } from '../entities/Track';
|
||||
|
||||
/**
|
||||
@@ -25,8 +26,7 @@ export class CreateTrack {
|
||||
*/
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
@IsPositive()
|
||||
minimumLapTime?: number;
|
||||
minimumLapTime: number;
|
||||
|
||||
/**
|
||||
* Creates a new Track entity from this.
|
||||
@@ -37,6 +37,9 @@ export class CreateTrack {
|
||||
newTrack.name = this.name;
|
||||
newTrack.distance = this.distance;
|
||||
newTrack.minimumLapTime = this.minimumLapTime;
|
||||
if (this.minimumLapTime < 0) {
|
||||
throw new TrackLapTimeCantBeNegativeError();
|
||||
}
|
||||
|
||||
return newTrack;
|
||||
}
|
||||
|
||||
@@ -43,10 +43,9 @@ export class Track {
|
||||
* The minimum time a runner should take to run a lap on this track.
|
||||
* Will be used for fraud detection.
|
||||
*/
|
||||
@Column()
|
||||
@Column({ nullable: true })
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
@IsPositive()
|
||||
minimumLapTime?: number;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { IsInt, IsOptional, IsString } from "class-validator";
|
||||
import { TrackLapTimeCantBeNegativeError } from '../../errors/TrackErrors';
|
||||
import { Track } from '../entities/Track';
|
||||
|
||||
/**
|
||||
@@ -40,5 +41,8 @@ export class ResponseTrack {
|
||||
this.name = track.name;
|
||||
this.distance = track.distance;
|
||||
this.minimumLapTime = track.minimumLapTime;
|
||||
if (this.minimumLapTime < 0) {
|
||||
throw new TrackLapTimeCantBeNegativeError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user