2020-12-04 17:34:14 +00:00
|
|
|
import { IsOptional, IsString } from 'class-validator';
|
|
|
|
import { UserGroup } from '../entities/UserGroup';
|
|
|
|
|
2020-12-21 15:21:12 +00:00
|
|
|
/**
|
|
|
|
* This classed is used to create a new UserGroup entity from a json body (post request).
|
|
|
|
*/
|
2020-12-04 17:34:14 +00:00
|
|
|
export class CreateUserGroup {
|
2020-12-05 09:31:24 +00:00
|
|
|
/**
|
|
|
|
* The new group's name.
|
|
|
|
*/
|
2020-12-04 17:34:14 +00:00
|
|
|
@IsString()
|
|
|
|
name: string;
|
2020-12-05 09:31:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The new group's description.
|
|
|
|
* Optinal.
|
|
|
|
*/
|
2020-12-04 17:34:14 +00:00
|
|
|
@IsOptional()
|
|
|
|
@IsString()
|
|
|
|
description?: string;
|
|
|
|
|
2020-12-05 09:31:24 +00:00
|
|
|
/**
|
2020-12-21 15:21:12 +00:00
|
|
|
* Creates a new UserGroup entity from this.
|
2020-12-05 09:31:24 +00:00
|
|
|
*/
|
2020-12-04 17:34:14 +00:00
|
|
|
public async toUserGroup(): Promise<UserGroup> {
|
|
|
|
let newUserGroup: UserGroup = new UserGroup();
|
|
|
|
|
2020-12-05 09:31:24 +00:00
|
|
|
newUserGroup.name = this.name;
|
|
|
|
newUserGroup.description = this.description;
|
2020-12-04 17:34:14 +00:00
|
|
|
|
|
|
|
return newUserGroup;
|
|
|
|
}
|
|
|
|
}
|