import { IsOptional, IsString } from 'class-validator'; import { UserGroup } from '../entities/UserGroup'; export class CreateUserGroup { /** * 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(); newUserGroup.name = this.name; newUserGroup.description = this.description; return newUserGroup; } }