diff --git a/backend/src/routes/auth/dto/register-am-complet.dto.ts b/backend/src/routes/auth/dto/register-am-complet.dto.ts index 16d0c89..78a9fb4 100644 --- a/backend/src/routes/auth/dto/register-am-complet.dto.ts +++ b/backend/src/routes/auth/dto/register-am-complet.dto.ts @@ -132,12 +132,36 @@ export class RegisterAMCompletDto { @IsDateString() date_agrement?: string; - @ApiProperty({ example: 4, description: 'Capacité d\'accueil (nombre d\'enfants)', minimum: 1, maximum: 10 }) + @ApiProperty({ + example: 4, + description: + "Capacité d'accueil (nombre d'enfants). Si absent, la valeur peut être prise de places_disponibles (alias).", + minimum: 1, + maximum: 10, + }) + @Transform(({ obj }) => { + const raw = obj.capacite_accueil ?? obj.places_disponibles; + if (raw === '' || raw === undefined || raw === null) return undefined; + return typeof raw === 'string' ? parseInt(String(raw), 10) : raw; + }) @IsInt() @Min(1, { message: 'La capacité doit être au moins 1' }) @Max(10, { message: 'La capacité ne peut pas dépasser 10' }) capacite_accueil: number; + /** Alias historique / client : même sémantique que capacite_accueil (évite forbidNonWhitelisted). */ + @ApiProperty({ + required: false, + description: 'Déprécié : utiliser capacite_accueil. Conservé pour compatibilité.', + minimum: 1, + maximum: 10, + }) + @IsOptional() + @IsInt() + @Min(1) + @Max(10) + places_disponibles?: number; + // ============================================ // ÉTAPE 3 : PRÉSENTATION (Optionnel) // ============================================