backend/src/models/responses/ResponseUserGroup.ts

42 lines
1.0 KiB
TypeScript

import { IsArray, IsNotEmpty, IsOptional, IsString } from "class-validator";
import { Permission } from '../entities/Permission';
import { UserGroup } from '../entities/UserGroup';
import { ResponsePrincipal } from './ResponsePrincipal';
/**
* Defines the userGroup response.
*/
export class ResponseUserGroup extends ResponsePrincipal {
/**
* The userGroup's name.
*/
@IsNotEmpty()
@IsString()
name: string;
/**
* The userGroup's description.
*/
@IsOptional()
@IsString()
description?: string;
/**
* The userGroup's permissions.
*/
@IsArray()
@IsOptional()
permissions: Permission[];
/**
* Creates a ResponseUserGroup object from a userGroup.
* @param group The userGroup the response shall be build for.
*/
public constructor(group: UserGroup) {
super(group);
this.name = group.name;
this.description = group.description;
this.permissions = group.permissions;
}
}