import { IsInt, IsPositive } from 'class-validator'; import { FixedDonation } from '../../entities/FixedDonation'; import { CreateDonation } from './CreateDonation'; /** * This class is used to create a new FixedDonation entity from a json body (post request). */ export class CreateFixedDonation extends CreateDonation { /** * The donation's amount. * The unit is your currency's smallest unit (default: euro cent). */ @IsInt() @IsPositive() amount: number; /** * Creates a new FixedDonation entity from this. */ public async toEntity(): Promise { let newDonation = new FixedDonation; newDonation.amount = this.amount; newDonation.donor = await this.getDonor(); return newDonation; } }