import { IsNotEmpty, IsOptional, IsString } from "class-validator"; import { ChildEntity, Column } from "typeorm"; import { ResponsePrincipal } from '../responses/ResponsePrincipal'; import { ResponseUserGroup } from '../responses/ResponseUserGroup'; import { Principal } from './Principal'; /** * Defines the UserGroup entity. * This entity describes a group of users with a set of permissions. */ @ChildEntity() export class UserGroup extends Principal { /** * The group's name */ @Column() @IsNotEmpty() @IsString() name: string; /** * The group's description */ @Column({ nullable: true }) @IsOptional() @IsString() description?: string; /** * Turns this entity into it's response class. */ public toResponse(): ResponsePrincipal { return new ResponseUserGroup(this); } }