using FluentValidation;
using GermanApp.Application.DTOs;
namespace GermanApp.Presentation.Validators;
///
/// Validator for CreateLessonDto.
/// Validates input when creating a new lesson.
///
public class CreateLessonValidator : AbstractValidator
{
public CreateLessonValidator()
{
RuleFor(x => x.Title)
.NotEmpty().WithMessage("Lesson title is required.")
.MinimumLength(3).WithMessage("Lesson title must be at least 3 characters long.")
.MaximumLength(200).WithMessage("Lesson title must not exceed 200 characters.");
RuleFor(x => x.Description)
.MaximumLength(2000).WithMessage("Lesson description must not exceed 2000 characters.");
RuleFor(x => x.LevelId)
.GreaterThan(0).WithMessage("Level ID must be greater than 0.");
RuleFor(x => x.Order)
.GreaterThanOrEqualTo(0).WithMessage("Order must be at least 0.")
.LessThanOrEqualTo(1000).WithMessage("Order must not exceed 1000.");
RuleFor(x => x.Topic)
.NotEmpty().WithMessage("Topic is required.")
.MinimumLength(2).WithMessage("Topic must be at least 2 characters long.")
.MaximumLength(100).WithMessage("Topic must not exceed 100 characters.");
}
}
///
/// Validator for UpdateLessonDto.
/// Validates input when updating an existing lesson.
///
public class UpdateLessonValidator : AbstractValidator
{
public UpdateLessonValidator()
{
RuleFor(x => x.Title)
.NotEmpty().WithMessage("Lesson title is required.")
.MinimumLength(3).WithMessage("Lesson title must be at least 3 characters long.")
.MaximumLength(200).WithMessage("Lesson title must not exceed 200 characters.");
RuleFor(x => x.Description)
.MaximumLength(2000).WithMessage("Lesson description must not exceed 2000 characters.");
RuleFor(x => x.LevelId)
.GreaterThan(0).WithMessage("Level ID must be greater than 0.");
RuleFor(x => x.Order)
.GreaterThanOrEqualTo(0).WithMessage("Order must be at least 0.")
.LessThanOrEqualTo(1000).WithMessage("Order must not exceed 1000.");
RuleFor(x => x.Topic)
.NotEmpty().WithMessage("Topic is required.")
.MinimumLength(2).WithMessage("Topic must be at least 2 characters long.")
.MaximumLength(100).WithMessage("Topic must not exceed 100 characters.");
}
}