import {
  IsString,
  IsOptional,
  IsInt,
  MaxLength,
  Matches,
  Min,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class CreateIndustryDto {
  @ApiProperty({ maxLength: 100, description: 'Name der Branche' })
  @IsString()
  @MaxLength(100)
  name!: string;

  @ApiPropertyOptional({
    maxLength: 7,
    default: '#6B7280',
    description: 'Hex-Farbcode (z.B. #3B82F6)',
  })
  @IsOptional()
  @IsString()
  @MaxLength(7)
  @Matches(/^#[0-9A-Fa-f]{6}$/, {
    message: 'color muss ein gueltiger Hex-Farbcode sein (z.B. #3B82F6)',
  })
  color?: string;

  @ApiPropertyOptional({ default: 0, description: 'Sortierreihenfolge' })
  @IsOptional()
  @IsInt()
  @Min(0)
  sortOrder?: number;
}
