import { IsObject, IsOptional } from 'class-validator'; import { Address } from '../../entities/Address'; import { RunnerOrganisation } from '../../entities/RunnerOrganisation'; import { CreateRunnerGroup } from './CreateRunnerGroup'; /** * This classed is used to create a new RunnerOrganisation entity from a json body (post request). */ export class CreateRunnerOrganisation extends CreateRunnerGroup { /** * The new organisation's address. */ @IsOptional() @IsObject() address?: Address; /** * Creates a new RunnerOrganisation entity from this. */ public async toEntity(): Promise { let newRunnerOrganisation: RunnerOrganisation = new RunnerOrganisation(); newRunnerOrganisation.name = this.name; newRunnerOrganisation.contact = await this.getContact(); newRunnerOrganisation.address = this.address; Address.validate(newRunnerOrganisation.address); return newRunnerOrganisation; } }