openWa / src /modules /session /dto /create-session.dto.ts
harsh
fix: standardized and widened validation for JIDs, phone numbers, and session names
b63a85d
Raw History Blame Contribute Delete
1.25 kB
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsString, IsOptional, MaxLength, MinLength, Matches, IsIn } from 'class-validator';
export class CreateSessionDto {
@ApiProperty({
description: 'Unique name for the session (alphanumeric, hyphens and underscores only)',
example: 'my-bot',
minLength: 3,
maxLength: 50,
})
@IsString()
@MinLength(3)
@MaxLength(50)
@Matches(/^[a-zA-Z0-9\-_]+$/, {
message: 'Session name can only contain letters, numbers, hyphens and underscores',
})
name: string;
@ApiPropertyOptional({
description: 'Session configuration options',
example: { autoReconnect: true },
})
@IsOptional()
config?: Record<string, unknown>;
// Phase 3: Proxy per session
@ApiPropertyOptional({
description: 'Proxy URL for this session (e.g., http://user:pass@proxy.example.com:8080)',
example: 'http://proxy.example.com:8080',
})
@IsOptional()
@IsString()
@MaxLength(255)
proxyUrl?: string;
@ApiPropertyOptional({
description: 'Proxy type',
enum: ['http', 'https', 'socks4', 'socks5'],
example: 'http',
})
@IsOptional()
@IsIn(['http', 'https', 'socks4', 'socks5'])
proxyType?: 'http' | 'https' | 'socks4' | 'socks5';
}