diff --git a/src/models/actions/create/CreateGroupContact.ts b/src/models/actions/create/CreateGroupContact.ts index c6538e8..e261f51 100644 --- a/src/models/actions/create/CreateGroupContact.ts +++ b/src/models/actions/create/CreateGroupContact.ts @@ -29,7 +29,7 @@ export class CreateGroupContact { lastname: string; /** - * The new contact's address. + * The new participant's address. */ @IsOptional() @IsObject() @@ -55,14 +55,14 @@ export class CreateGroupContact { * Creates a new Address entity from this. */ public async toEntity(): Promise { - let contact: GroupContact = new GroupContact(); - contact.firstname = this.firstname; - contact.middlename = this.middlename; - contact.lastname = this.lastname; - contact.email = this.email; - contact.phone = this.phone; - contact.address = this.address; - Address.validate(contact.address); - return contact; + let newContact: GroupContact = new GroupContact(); + newContact.firstname = this.firstname; + newContact.middlename = this.middlename; + newContact.lastname = this.lastname; + newContact.email = this.email; + newContact.phone = this.phone; + newContact.address = this.address; + Address.validate(newContact.address); + return newContact; } } \ No newline at end of file diff --git a/src/models/entities/Address.ts b/src/models/entities/Address.ts index 21ec92a..6526c08 100644 --- a/src/models/entities/Address.ts +++ b/src/models/entities/Address.ts @@ -1,6 +1,4 @@ import { - IsNotEmpty, - IsOptional, IsPostalCode, IsString } from "class-validator"; @@ -18,10 +16,9 @@ export class Address { * The address's first line. * Containing the street and house number. */ - @Column() + @Column({ nullable: true }) @IsString() - @IsNotEmpty() - address1: string; + address1?: string; /** * The address's second line. @@ -29,33 +26,29 @@ export class Address { */ @Column({ nullable: true }) @IsString() - @IsOptional() address2?: string; /** * The address's postal code. * This will get checked against the postal code syntax for the configured country. */ - @Column() + @Column({ nullable: true }) @IsString() - @IsNotEmpty() @IsPostalCode(config.postalcode_validation_countrycode) postalcode: string; /** * The address's city. */ - @Column() + @Column({ nullable: true }) @IsString() - @IsNotEmpty() city: string; /** * The address's country. */ - @Column() + @Column({ nullable: true }) @IsString() - @IsNotEmpty() country: string; public reset() { diff --git a/src/models/entities/GroupContact.ts b/src/models/entities/GroupContact.ts index 17b0b9b..dd6eed1 100644 --- a/src/models/entities/GroupContact.ts +++ b/src/models/entities/GroupContact.ts @@ -54,7 +54,6 @@ export class GroupContact { * The contact's address. * This is a address object to prevent any formatting differences. */ - @IsOptional() @Column(type => Address) address?: Address;