import { Transform } from 'class-transformer'; import { IsEnum, IsOptional, IsString, MaxLength, MinLength, ValidateIf } from 'class-validator'; import { InspectionCompanySignatureManifestation } from '../../database/entities'; import { CreateInspectionSignatureDto } from './create-inspection-signature.dto'; export class CreateCompanySignatureDto extends CreateInspectionSignatureDto { @IsOptional() @IsEnum(InspectionCompanySignatureManifestation) manifestation?: InspectionCompanySignatureManifestation; @ValidateIf((dto: CreateCompanySignatureDto) => dto.manifestation === InspectionCompanySignatureManifestation.DISSENT, ) @Transform(({ value }) => (typeof value === 'string' ? value.trim() : value)) @IsString() @MinLength(10) @MaxLength(4000) statement?: string; }