Files
dh-inspeccion-v2/api-v3/src/administration/users/dto/create-user.dto.ts
T
admin 7fe59bccd2
Android CI / RC / Android · lint, tests, debug APK, release compile (push) Failing after 1m25s
DH V2 CI / API · typecheck, tests, build (push) Successful in 34s
DH V2 CI / WEB · typecheck, build (push) Successful in 20s
Production dependency audit / API · production dependencies (push) Successful in 9s
Production dependency audit / WEB · production dependencies (push) Successful in 9s
DH V2 CI / Docker / scripts contract (push) Successful in 1m16s
feat(f6.2): add per-act representative signing and user smtp
2026-09-14 15:53:55 -03:00

86 lines
1.7 KiB
TypeScript

import { Transform } from 'class-transformer';
import {
ArrayUnique,
IsArray,
IsBoolean,
IsEmail,
IsOptional,
IsString,
IsUUID,
Matches,
MaxLength,
MinLength,
} from 'class-validator';
const optionalText = ({ value }: { value: unknown }) =>
typeof value === 'string' && value.trim() ? value.trim() : null;
export class CreateUserDto {
@Transform(({ value }) =>
typeof value === 'string' ? value.trim().toLowerCase() : value,
)
@IsString()
@MinLength(3)
@MaxLength(80)
@Matches(/^[a-zA-Z0-9._-]+$/)
username!: string;
@Transform(({ value }) =>
typeof value === 'string' && value.trim() ? value.trim().toLowerCase() : null,
)
@IsEmail()
@MaxLength(320)
email!: string;
@Transform(({ value }) =>
typeof value === 'string' && value.trim() ? value.replace(/\D/g, '') : null,
)
@IsOptional()
@Matches(/^\d{7,11}$/)
dni?: string | null;
@Transform(optionalText)
@IsOptional()
@IsString()
@MaxLength(40)
phone?: string | null;
@Transform(optionalText)
@IsOptional()
@IsString()
@MaxLength(160)
jobTitle?: string | null;
@Transform(optionalText)
@IsOptional()
@IsString()
@MaxLength(80)
employeeNumber?: string | null;
@IsString()
@MinLength(12)
@MaxLength(128)
password!: string;
@Transform(({ value }) => (typeof value === 'string' ? value.trim() : value))
@IsString()
@MinLength(1)
@MaxLength(120)
firstName!: string;
@Transform(({ value }) => (typeof value === 'string' ? value.trim() : value))
@IsString()
@MinLength(1)
@MaxLength(120)
lastName!: string;
@IsOptional()
@IsBoolean()
mustChangePassword = true;
@IsArray()
@ArrayUnique()
@IsUUID('4', { each: true })
roleIds!: string[];
}