import { IsString, IsOptional, IsInt, IsBoolean, IsIn, IsNotEmpty, Matches, MaxLength, Min } from 'class-validator';

export class CreateExpenseTypeDto {
  @IsString()
  @IsNotEmpty()
  @MaxLength(30)
  @Matches(/^[a-z][a-z0-9_]*$/)
  code: string;

  @IsString()
  @IsNotEmpty()
  @MaxLength(30)
  @Matches(/\S/)
  name: string;

  @IsOptional()
  @IsIn(['room', 'personal', 'both'])
  category?: string;

  @IsOptional()
  @IsInt()
  @Min(0)
  sortOrder?: number;
}

export class UpdateExpenseTypeDto {
  @IsOptional()
  @IsString()
  @IsNotEmpty()
  @MaxLength(30)
  @Matches(/\S/)
  name?: string;

  @IsOptional()
  @IsIn(['room', 'personal', 'both'])
  category?: string;

  @IsOptional()
  @IsInt()
  @Min(0)
  sortOrder?: number;

  @IsOptional()
  @IsBoolean()
  enabled?: boolean;
}
