From 644d2b06ace012cb43d9d2b0ce38146b8586841f Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Fri, 15 Jan 2021 18:13:53 +0100 Subject: [PATCH] Removed useless part from function and updated comments ref #90 --- .../actions/create/CreateParticipant.ts | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/models/actions/create/CreateParticipant.ts b/src/models/actions/create/CreateParticipant.ts index 17e7c56..3d7c386 100644 --- a/src/models/actions/create/CreateParticipant.ts +++ b/src/models/actions/create/CreateParticipant.ts @@ -1,7 +1,7 @@ import { IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsString } from 'class-validator'; import { getConnectionManager } from 'typeorm'; import { config } from '../../../config'; -import { AddressNotFoundError, AddressWrongTypeError } from '../../../errors/AddressErrors'; +import { AddressNotFoundError } from '../../../errors/AddressErrors'; import { Address } from '../../entities/Address'; /** @@ -47,26 +47,18 @@ export abstract class CreateParticipant { email?: string; /** - * The new participant's address. - * Must be of type number (address id). + * The new participant's address's id. */ @IsInt() @IsOptional() address?: number; /** - * Gets the new participant's address by it's address. + * Gets the new participant's address by it's id. */ public async getAddress(): Promise
{ - if (this.address === undefined || this.address === null) { - return null; - } - if (!isNaN(this.address)) { - let address = await getConnectionManager().get().getRepository(Address).findOne({ id: this.address }); - if (!address) { throw new AddressNotFoundError; } - return address; - } - - throw new AddressWrongTypeError; + let address = await getConnectionManager().get().getRepository(Address).findOne({ id: this.address }); + if (!address) { throw new AddressNotFoundError; } + return address; } } \ No newline at end of file