using FastEndpoints; using FluentValidation; using MetaCourse.Api.DTOs.Topics; namespace MetaCourse.Api.Validators.Topics; public class UpdateTopicDtoValidator : Validator { public UpdateTopicDtoValidator() { RuleFor(x => x.Id) .NotEqual(Guid.Empty).WithMessage("L'identifiant est invalide."); RuleFor(x => x.Title) .NotEmpty().WithMessage("Le titre est requis.") .MinimumLength(2).WithMessage("Le titre doit contenir au moins 2 caractères.") .MaximumLength(200).WithMessage("Le titre ne peut pas dépasser 200 caractères."); When(x => x.Description != null, () => { RuleFor(x => x.Description) .MaximumLength(1000).WithMessage("La description ne peut pas dépasser 1000 caractères."); }); RuleFor(x => x.Position) .GreaterThan(0).WithMessage("La position doit être supérieure à 0."); } }