33
src/models/actions/create/CreateUserGroup.ts
Normal file
33
src/models/actions/create/CreateUserGroup.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { IsOptional, IsString } from 'class-validator';
|
||||
import { UserGroup } from '../entities/UserGroup';
|
||||
|
||||
/**
|
||||
* This classed is used to create a new UserGroup entity from a json body (post request).
|
||||
*/
|
||||
export class CreateUserGroup {
|
||||
/**
|
||||
* The new group's name.
|
||||
*/
|
||||
@IsString()
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The new group's description.
|
||||
* Optinal.
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
description?: string;
|
||||
|
||||
/**
|
||||
* Creates a new UserGroup entity from this.
|
||||
*/
|
||||
public async toUserGroup(): Promise<UserGroup> {
|
||||
let newUserGroup: UserGroup = new UserGroup();
|
||||
|
||||
newUserGroup.name = this.name;
|
||||
newUserGroup.description = this.description;
|
||||
|
||||
return newUserGroup;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user