import { ApiProperty } from '@nestjs/swagger'; import { IsBoolean, IsDateString, IsEmail, IsEnum, IsNotEmpty, IsOptional, IsString, MinLength, MaxLength, } from 'class-validator'; import { RoleType, GenreType, StatutUtilisateurType } from 'src/entities/users.entity'; export class CreateUserDto { @ApiProperty({ example: 'sosso.test@example.com' }) @IsEmail() @IsNotEmpty() email: string; @ApiProperty({ minLength: 6, example: 'Mon_motdepasse_fort_1234?' }) @IsString() @IsNotEmpty() @MinLength(6) password: string; @ApiProperty({ example: 'Julien' }) @IsString() @IsNotEmpty() @MaxLength(100) prenom: string; @ApiProperty({ example: 'Dupont' }) @IsString() @IsNotEmpty() @MaxLength(100) nom: string; @ApiProperty({ enum: GenreType, required: false, default: GenreType.AUTRE }) @IsOptional() @IsEnum(GenreType) genre?: GenreType = GenreType.AUTRE; @ApiProperty({ enum: RoleType }) @IsEnum(RoleType) role: RoleType; @ApiProperty({ enum: StatutUtilisateurType, required: false, default: StatutUtilisateurType.EN_ATTENTE }) @IsOptional() @IsEnum(StatutUtilisateurType) statut?: StatutUtilisateurType = StatutUtilisateurType.EN_ATTENTE; @ApiProperty({ example: '+33123456789' }) @IsString() @IsNotEmpty() @MaxLength(20) telephone: string; @ApiProperty({ example: 'Paris', required: false }) @IsOptional() @IsString() @MaxLength(150) ville?: string; @ApiProperty({ example: '75000', required: false }) @IsOptional() @IsString() @MaxLength(10) code_postal?: string; @ApiProperty({ example: '10 rue de la paix, 75000 Paris' }) @IsString() @IsNotEmpty() adresse: string; @ApiProperty({ example: 'https://example.com/photo.jpg', required: false }) @IsOptional() @IsString() photo_url?: string; @ApiProperty({ default: false }) @IsOptional() @IsBoolean() consentement_photo?: boolean = false; @ApiProperty({ required: false }) @IsOptional() @IsDateString({}, { message: 'date_consentement_photo doit ĂȘtre une date ISO valide' }) date_consentement_photo?: string | null; @ApiProperty({ default: false }) @IsOptional() @IsBoolean() changement_mdp_obligatoire?: boolean = false; @ApiProperty({ example: true }) @IsBoolean() @IsNotEmpty() cguAccepted: boolean; }