52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
import {
|
|
ArrayNotEmpty,
|
|
IsArray,
|
|
IsNotEmpty,
|
|
IsOptional,
|
|
IsString,
|
|
IsUUID,
|
|
} from 'class-validator';
|
|
|
|
export class CreateRoleDto {
|
|
@ApiProperty({ example: 'Flight Disruption Lead' })
|
|
@IsString()
|
|
@IsNotEmpty({ message: 'Role name is required' })
|
|
name!: string;
|
|
|
|
@ApiPropertyOptional({ example: 'Manages flight recovery incident workflows and exceptions' })
|
|
@IsString()
|
|
@IsOptional()
|
|
description?: string;
|
|
|
|
@ApiProperty({
|
|
example: ['11111111-1111-1111-1111-111111111111', '22222222-2222-2222-2222-222222222222'],
|
|
description: 'Array of Permission UUIDs to assign to this role',
|
|
})
|
|
@IsArray()
|
|
@ArrayNotEmpty({ message: 'At least one permission must be assigned to the role' })
|
|
@IsUUID('all', { each: true, message: 'Each permission ID must be a valid UUID' })
|
|
permissionIds!: string[];
|
|
}
|
|
|
|
export class UpdateRoleDto {
|
|
@ApiPropertyOptional({ example: 'Flight Disruption Lead' })
|
|
@IsString()
|
|
@IsOptional()
|
|
name?: string;
|
|
|
|
@ApiPropertyOptional({ example: 'Updated description of role responsibilities' })
|
|
@IsString()
|
|
@IsOptional()
|
|
description?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
example: ['11111111-1111-1111-1111-111111111111'],
|
|
description: 'Updated array of Permission UUIDs for this role',
|
|
})
|
|
@IsArray()
|
|
@IsOptional()
|
|
@IsUUID('all', { each: true, message: 'Each permission ID must be a valid UUID' })
|
|
permissionIds?: string[];
|
|
}
|