Files
BeReadyBackend/BeReadyBackend/Validators/Groups/CreateGroupDtoValidator.cs
T
2026-03-24 18:02:10 +01:00

41 lines
1.3 KiB
C#

using BeReadyBackend.DTO.Groups;
using FastEndpoints;
using FluentValidation;
namespace BeReadyBackend.Validators.Groups;
public class CreateGroupDtoValidator : Validator<CreateGroupDto>
{
public CreateGroupDtoValidator()
{
RuleFor(x => x.Label)
.NotEmpty()
.WithMessage("Label cannot be empty")
.MaximumLength(100)
.WithMessage("Label cannot exceed 100 characters")
.MinimumLength(2)
.WithMessage("Label must exceed 2 characters");
RuleFor(x => x.Title)
.NotEmpty()
.WithMessage("Title cannot be empty")
.MaximumLength(50)
.WithMessage("Title cannot exceed 50 characters")
.MinimumLength(2)
.WithMessage("Title must exceed 2 characters");
RuleFor(x => x.Description)
.NotEmpty()
.WithMessage("Description cannot be empty")
.MaximumLength(200)
.WithMessage("Description cannot exceed 200 characters")
.MinimumLength(2)
.WithMessage("Description must exceed 2 characters");
RuleFor(x => x.Duration)
.NotEmpty()
.WithMessage("Duration cannot be empty")
.GreaterThan(0)
.WithMessage("Duration must exceed 1 hour");
}
}