import { ISO_DATE } from '@humand-packages/common';
import { Expose, Type } from 'class-transformer';
import { ArrayMinSize, IsArray, IsDefined, IsOptional, IsString, MaxLength, ValidateNested } from 'class-validator';
import { IsValidDate } from '../../../../../middlewares/dateValidator';
import { RuleLogicVC } from './rulesVC';

export class CreateHourCategoryVC {
    @IsDefined()
    @Expose()
    @IsString()
    @MaxLength(255)
    name!: string;

    @IsOptional()
    @Expose()
    @IsString()
    @MaxLength(1000)
    description?: string;

    @IsDefined()
    @Expose()
    @IsString()
    @IsValidDate(ISO_DATE)
    effectiveFrom!: string;

    @IsDefined()
    @Expose()
    @IsArray()
    @ArrayMinSize(1)
    @ValidateNested({ each: true })
    @Type(() => RuleLogicVC)
    rules!: RuleLogicVC[];
}
