24 lines
840 B
C#
24 lines
840 B
C#
using FastEndpoints;
|
|
using FluentValidation;
|
|
using MetaCourse.Api.DTOs.Courses;
|
|
|
|
namespace MetaCourse.Api.Validators.Courses;
|
|
|
|
public class UpdateCourseDtoValidator : Validator<UpdateCourseDto>
|
|
{
|
|
public UpdateCourseDtoValidator()
|
|
{
|
|
RuleFor(x => x.Id)
|
|
.NotEqual(Guid.Empty).WithMessage("L'identifiant est invalide.");
|
|
|
|
RuleFor(x => x.Title)
|
|
.NotEmpty().WithMessage("Le titre est requis.")
|
|
.MinimumLength(3).WithMessage("Le titre doit contenir au moins 3 caractères.")
|
|
.MaximumLength(200).WithMessage("Le titre ne peut pas dépasser 200 caractères.");
|
|
|
|
RuleFor(x => x.Description)
|
|
.NotEmpty().WithMessage("La description est requise.")
|
|
.MaximumLength(2000).WithMessage("La description ne peut pas dépasser 2000 caractères.");
|
|
}
|
|
}
|