feat(f4): add superadmin SMTP settings DTO

This commit is contained in:
2026-09-07 21:01:14 -03:00
parent a7f53f32f0
commit 489fb309b3
@@ -0,0 +1,71 @@
import { Transform, Type } from 'class-transformer';
import {
IsBoolean,
IsEmail,
IsEnum,
IsInt,
IsOptional,
IsString,
Max,
MaxLength,
Min,
MinLength,
} from 'class-validator';
import { SmtpSecurityMode } from '../../database/entities';
export class UpdateSmtpSettingsDto {
@Transform(({ value }) => typeof value === 'string' ? value.trim() : value)
@IsString()
@MinLength(1)
@MaxLength(255)
host!: string;
@Type(() => Number)
@IsInt()
@Min(1)
@Max(65535)
port!: number;
@IsEnum(SmtpSecurityMode)
securityMode!: SmtpSecurityMode;
@IsOptional()
@Transform(({ value }) => typeof value === 'string' ? value.trim() || null : value)
@IsString()
@MaxLength(255)
username?: string | null;
/** Omitir para conservar la clave actual; enviar null/cadena vacía para quitarla. */
@IsOptional()
@IsString()
@MaxLength(1000)
password?: string | null;
@Transform(({ value }) => typeof value === 'string' ? value.trim() : value)
@IsString()
@MinLength(1)
@MaxLength(200)
fromName!: string;
@Transform(({ value }) => typeof value === 'string' ? value.trim().toLowerCase() : value)
@IsEmail()
@MaxLength(320)
fromEmail!: string;
@IsOptional()
@Transform(({ value }) => typeof value === 'string' && value.trim() ? value.trim().toLowerCase() : null)
@IsEmail()
@MaxLength(320)
replyTo?: string | null;
@Transform(({ value }) => value === true || value === 'true')
@IsBoolean()
enabled!: boolean;
}
export class TestSmtpSettingsDto {
@Transform(({ value }) => typeof value === 'string' ? value.trim().toLowerCase() : value)
@IsEmail()
@MaxLength(320)
email!: string;
}