backend/src/models/responses/ResponseParticipant.ts

57 lines
1.2 KiB
TypeScript

import { IsInt, IsString } from "class-validator";
import { Participant } from '../entities/Participant';
/**
* Defines the participant response.
*/
export abstract class ResponseParticipant {
/**
* The participant's id.
*/
@IsInt()
id: number;
/**
* The participant's first name.
*/
@IsString()
firstname: string;
/**
* The participant's middle name.
*/
@IsString()
middlename?: string;
/**
* The participant's last name.
*/
@IsString()
lastname: string;
/**
* The participant's phone number.
*/
@IsString()
phone?: string;
/**
* The participant's e-mail address.
*/
@IsString()
email?: string;
/**
* Creates a ResponseParticipant object from a participant.
* @param participant The participant the response shall be build for.
*/
public constructor(participant: Participant) {
this.id = participant.id;
this.firstname = participant.firstname;
this.middlename = participant.middlename;
this.lastname = participant.lastname;
this.phone = participant.phone;
this.email = participant.email;
}
}