Switched the create classes over to the new address implementation

ref #105
This commit is contained in:
2021-01-16 16:55:30 +01:00
parent dafac06bc8
commit 2cd15d25e9
5 changed files with 13 additions and 48 deletions

View File

@@ -1,7 +1,5 @@
import { IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsString } from 'class-validator';
import { getConnectionManager } from 'typeorm';
import { IsEmail, IsNotEmpty, IsObject, IsOptional, IsPhoneNumber, IsString } from 'class-validator';
import { config } from '../../../config';
import { AddressNotFoundError } from '../../../errors/AddressErrors';
import { Address } from '../../entities/Address';
/**
@@ -49,17 +47,7 @@ export abstract class CreateParticipant {
/**
* The new participant's address's id.
*/
@IsInt()
@IsOptional()
address?: number;
/**
* Gets the new participant's address by it's id.
*/
public async getAddress(): Promise<Address> {
if (!this.address) { return null; }
let address = await getConnectionManager().get().getRepository(Address).findOne({ id: this.address });
if (!address) { throw new AddressNotFoundError; }
return address;
}
@IsObject()
address?: Address;
}