diff --git a/src/models/creation/CreateUserGroup.ts b/src/models/creation/CreateUserGroup.ts index d55618c..959bea5 100644 --- a/src/models/creation/CreateUserGroup.ts +++ b/src/models/creation/CreateUserGroup.ts @@ -1,28 +1,30 @@ import { IsOptional, IsString } from 'class-validator'; -import { GroupNameNeededError } from '../../errors/UserGroupErrors'; import { UserGroup } from '../entities/UserGroup'; export class CreateUserGroup { - @IsOptional() + /** + * The new group's name. + */ @IsString() name: string; + + /** + * The new group's description. + * Optinal. + */ @IsOptional() @IsString() description?: string; + /** + * Converts this to a UserGroup entity. + */ public async toUserGroup(): Promise { let newUserGroup: UserGroup = new UserGroup(); - if (this.name === undefined) { - throw new GroupNameNeededError(); - } + newUserGroup.name = this.name; + newUserGroup.description = this.description; - newUserGroup.name = this.name - if (this.description) { - newUserGroup.description = this.description - } - - console.log(newUserGroup) return newUserGroup; } } \ No newline at end of file