import { IsArray, IsIn, IsNotEmpty, IsOptional, IsString, IsNumber, MinLength, MaxLength, ArrayMinSize, ArrayMaxSize } from 'class-validator';
import { Type } from 'class-transformer';

export class CreateNotificationDto {
    @IsString()
    @IsNotEmpty()
    @MinLength(1, { message: 'Subject must not be empty' })
    @MaxLength(200, { message: 'Subject must not exceed 200 characters' })
    subject: string;

    @IsString()
    @IsNotEmpty()
    @MinLength(1, { message: 'Message must not be empty' })
    @MaxLength(5000, { message: 'Message must not exceed 5000 characters' })
    message: string;

    @IsIn(['email', 'web'])
    type: 'email' | 'web';

    @IsOptional()
    @IsArray()
    @ArrayMaxSize(1000, { message: 'Cannot specify more than 1000 individual recipients' })
    @IsString({ each: true })
    recipients?: string[];

    @IsOptional()
    @IsString()
    academicYearId?: string;

    @IsOptional()
    @IsString()
    classId?: string;

    @IsOptional()
    @IsString()
    sectionId?: string;

    @IsOptional()
    @IsArray()
    @ArrayMinSize(1)
    @IsString({ each: true })
    @IsIn(['web', 'sms'], { each: true })
    channels?: string[];

    // File metadata from Cloudinary uploads
    @IsOptional()
    @IsString()
    fileUrl?: string;

    @IsOptional()
    @IsString()
    fileName?: string;

    @IsOptional()
    @IsString()
    fileType?: string;

    @IsOptional()
    @Type(() => Number)
    @IsNumber()
    fileSize?: number;
}
