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

import { Type } from 'class-transformer';

export class CreateTranslationDto {
  @IsString()
  @IsNotEmpty()
  @MaxLength(150)
  @Matches(/^[a-zA-Z0-9._-]+$/, {
    message:
      'translationKey can only contain letters, numbers, dots, underscores and hyphens',
  })
  translationKey!: string;

  @IsString()
  @IsNotEmpty()
  englishText!: string;

  @IsString()
  @IsNotEmpty()
  khmerText!: string;

  @IsString()
  @IsNotEmpty()
  @MaxLength(50)
  @Matches(/^[a-zA-Z0-9_-]+$/, {
    message:
      'module can only contain letters, numbers, underscores and hyphens',
  })
  module!: string;

  @IsString()
  @IsNotEmpty()
  @MaxLength(100)
  @Matches(/^[a-zA-Z0-9_-]+$/, {
    message: 'page can only contain letters, numbers, underscores and hyphens',
  })
  page!: string;

  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  parentId?: number | null;

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