@@ -1,9 +1,8 @@
|
||||
import { IsObject } from 'class-validator';
|
||||
import { IsInt, IsOptional } from 'class-validator';
|
||||
import { getConnectionManager } from 'typeorm';
|
||||
import { AddressNotFoundError, AddressWrongTypeError } from '../../errors/AddressErrors';
|
||||
import { Address } from '../entities/Address';
|
||||
import { RunnerOrganisation } from '../entities/RunnerOrganisation';
|
||||
import { CreateAddress } from './CreateAddress';
|
||||
import { CreateRunnerGroup } from './CreateRunnerGroup';
|
||||
|
||||
export class CreateRunnerOrganisation extends CreateRunnerGroup {
|
||||
@@ -12,8 +11,9 @@ export class CreateRunnerOrganisation extends CreateRunnerGroup {
|
||||
* Must be of type number (address id), createAddress (new address) or address (existing address)
|
||||
* Optional.
|
||||
*/
|
||||
@IsObject()
|
||||
address?: number | CreateAddress | Address;
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
address?: number;
|
||||
|
||||
/**
|
||||
* Creates a Participant entity from this.
|
||||
@@ -22,12 +22,6 @@ export class CreateRunnerOrganisation extends CreateRunnerGroup {
|
||||
if (this.address === undefined) {
|
||||
return null;
|
||||
}
|
||||
if (this.address! instanceof Address) {
|
||||
return this.address;
|
||||
}
|
||||
if (this.address! instanceof CreateAddress) {
|
||||
return this.address.toAddress();
|
||||
}
|
||||
if (!isNaN(this.address)) {
|
||||
let address = await getConnectionManager().get().getRepository(Address).findOne({ id: this.address });
|
||||
if (!address) { throw new AddressNotFoundError; }
|
||||
|
||||
Reference in New Issue
Block a user