Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

930 B
Raw Blame
import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, IsString, Matches, MaxLength } from 'class-validator';
import { CHAT_ID_MAX_LENGTH } from '../../message/dto/send-message.dto';
import { ToStrictString } from '../../../common/utils/strict-boolean';

export class DeleteChatDto {
  @ApiProperty({
    maxLength: CHAT_ID_MAX_LENGTH,
    description: "Chat ID in the active engine's native format (e.g. [email protected] on whatsapp-web.js)",
    example: '[email protected]',
  })
  @ToStrictString()
  @IsString()
  @IsNotEmpty()
  @MaxLength(CHAT_ID_MAX_LENGTH)
  // Engine-neutral structural check (localpart@host, no whitespace) so a different engine's JID scheme
  // (e.g. Baileys `…@s.whatsapp.net`) is accepted too; the adapter validates/normalises for its engine.
  @Matches(/^[^\s@]+@[^\s@]+$/, {
    message: 'chatId must be a valid chat JID in the form localpart@host',
  })
  chatId!: string;
}