From 22e6070e5316b01a50fd29a4cfda2b3d0cef81c9 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Fri, 15 Jan 2021 18:19:26 +0100 Subject: [PATCH] Removed useless part from function and updated comments ref #90 --- src/models/actions/create/CreateRunnerGroup.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/models/actions/create/CreateRunnerGroup.ts b/src/models/actions/create/CreateRunnerGroup.ts index 0b62024..aadea29 100644 --- a/src/models/actions/create/CreateRunnerGroup.ts +++ b/src/models/actions/create/CreateRunnerGroup.ts @@ -1,6 +1,6 @@ import { IsInt, IsNotEmpty, IsOptional, IsString } from 'class-validator'; import { getConnectionManager } from 'typeorm'; -import { GroupContactNotFoundError, GroupContactWrongTypeError } from '../../../errors/GroupContactErrors'; +import { GroupContactNotFoundError } from '../../../errors/GroupContactErrors'; import { GroupContact } from '../../entities/GroupContact'; /** @@ -15,7 +15,7 @@ export abstract class CreateRunnerGroup { name: string; /** - * The new group's contact. + * The new group's contact's id. * Optional */ @IsInt() @@ -26,15 +26,10 @@ export abstract class CreateRunnerGroup { * Gets the new group's contact by it's id. */ public async getContact(): Promise { - if (this.contact === undefined || this.contact === null) { - return null; - } - if (!isNaN(this.contact)) { - let contact = await getConnectionManager().get().getRepository(GroupContact).findOne({ id: this.contact }); - if (!contact) { throw new GroupContactNotFoundError; } - return contact; - } + if (!this.contact) { return null; } + let contact = await getConnectionManager().get().getRepository(GroupContact).findOne({ id: this.contact }); + if (!contact) { throw new GroupContactNotFoundError; } + return contact; - throw new GroupContactWrongTypeError; } } \ No newline at end of file