import { IsNotEmpty, IsString, IsOptional, IsArray, ValidateNested, ArrayMinSize } from 'class-validator';
import { Type } from 'class-transformer';
import { validationMessages } from '../../../messages/validation-messages';
import { ApiProperty } from '@nestjs/swagger';
import { TranslationDto } from './create.dto';

export class UpdateDto {
    @ApiProperty({ example: 'LINK', required: false, type: 'string' })
    @IsOptional()
    @IsString()
    image?: string;

    @ApiProperty({ example: 'ABC,XYZ,PQR', required: false, type: 'string' })
    @IsOptional()
    @IsString()
    tags?: string;

    @ApiProperty({ 
        example: [
            {
                language_code: 'en',
                description: 'ssdsd',
                title: 'English Category'
            },
            {
                language_code: 'cn',
                description: 'ssdsd',
                title: 'English Category'
            }
        ], 
        required: true, 
        type: [TranslationDto] 
    })
    @IsArray()
    @ArrayMinSize(1, { message: validationMessages.categories.translations_required })
    @ValidateNested({ each: true })
    @Type(() => TranslationDto)
    translations: TranslationDto[];
}
