namespace Application.Students.Queries;

using Application.Common;
using FluentValidation;

/// <summary>
/// Validator for <see cref="GetStudentsPagedQuery"/>.
/// Validates pagination parameters.
/// </summary>
public class GetStudentsPagedValidator : AbstractValidator<GetStudentsPagedQuery>
{
    public GetStudentsPagedValidator()
    {
        RuleFor(x => x.PageSize)
            .GreaterThan(0).WithMessage("Page size must be greater than 0")
            .LessThanOrEqualTo(50).WithMessage("Page size must not exceed 50");

        RuleFor(x => x.AfterCursor)
            .GreaterThan(0).WithMessage(ValidationPatterns.InvalidIdMessage)
            .When(x => x.AfterCursor.HasValue);
    }
}
