24 lines
860 B
C#
24 lines
860 B
C#
using FastEndpoints;
|
|
using FluentValidation;
|
|
using MetaCourse.Api.DTOs.Courses;
|
|
|
|
namespace MetaCourse.Api.Validators.Courses;
|
|
|
|
public class CreateCourseDtoValidator : Validator<CreateCourseDto>
|
|
{
|
|
public CreateCourseDtoValidator()
|
|
{
|
|
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.");
|
|
|
|
RuleFor(x => x.CreatorId)
|
|
.NotEqual(Guid.Empty).WithMessage("L'identifiant du créateur est invalide.");
|
|
}
|
|
}
|