From f350007ae5696a16ecb1994bf3b4be843781b91d Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Tue, 1 Dec 2020 17:20:43 +0100 Subject: [PATCH] Added participant abstract class ref #11 --- src/models/IParticipant.ts | 73 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/models/IParticipant.ts diff --git a/src/models/IParticipant.ts b/src/models/IParticipant.ts new file mode 100644 index 0000000..440e5e2 --- /dev/null +++ b/src/models/IParticipant.ts @@ -0,0 +1,73 @@ +import { Entity, PrimaryGeneratedColumn, Column } from "typeorm"; +import { + IsEmail, + IsInt, + IsNotEmpty, + IsOptional, + IsPhoneNumber, + IsString, +} from "class-validator"; + +/** + * Defines the participant interface. +*/ +export abstract class IParticipant { + /** + * Autogenerated unique id (primary key). + */ + @PrimaryGeneratedColumn() + @IsOptional() + @IsInt() + id: number; + + /** + * The participant's first name. + */ + @Column() + @IsNotEmpty() + @IsString() + firstname: string; + + /** + * The participant's middle name. + * Optional + */ + @Column() + @IsOptional() + @IsString() + middlename?: string; + + /** + * The participant's last name. + */ + @Column() + @IsOptional() + @IsString() + lastname: string; + + /** + * The participant's address. + * Optional + */ + @Column() + @IsOptional() + address?: Location; + + /** + * The participant's phone number. + * Optional + */ + @Column() + @IsOptional() + @IsPhoneNumber("DE") + phone?: string; + + /** + * The participant's email address. + * Optional + */ + @Column() + @IsOptional() + @IsEmail() + email?: string; +}