import { Type } from 'class-transformer';
import { IsArray, IsIn, IsNotEmpty, IsString, ValidateNested, Matches } from 'class-validator';

class BulkEntryDto {
    @IsString()
    @IsNotEmpty()
    studentId: string;

    @IsIn(['present', 'absent'])
    status: 'present' | 'absent';
}

export class BulkMarkDto {
    @IsString()
    @IsNotEmpty()
    @Matches(/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/, {
        message: 'date must be in YYYY-MM-DD format',
    })
    date: string; // 'YYYY-MM-DD'

    @IsArray()
    @ValidateNested({ each: true })
    @Type(() => BulkEntryDto)
    entries: BulkEntryDto[];
}
