< Summary - Heimdall API

Information
Class: ArturRios.Heimdall.Query.Input.Validation.PaginatedQueryValidator<T>
Assembly: ArturRios.Heimdall.Query
File(s): /home/runner/work/heimdall-api/heimdall-api/src/Application/ArturRios.Heimdall.Query/Input/Validation/PaginatedQueryValidator.cs
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 39
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage
100%
Covered methods: 1
Fully covered methods: 1
Total methods: 1
Method coverage: 100%
Full method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%

File(s)

/home/runner/work/heimdall-api/heimdall-api/src/Application/ArturRios.Heimdall.Query/Input/Validation/PaginatedQueryValidator.cs

#LineLine coverage
 1using ArturRios.Heimdall.Shared.Messages;
 2using ArturRios.Mediator.Query;
 3using FluentValidation;
 4
 5namespace ArturRios.Heimdall.Query.Input.Validation;
 6
 7/// <summary>
 8///     Shared pagination rules for every paginated list query (NFR-10): <c>PageNumber</c> must be at
 9///     least 1, and <c>PageSize</c> must fall within <see cref="MaxPageSize" />. Concrete query
 10///     validators derive from this and add their own filter-length rules on top — FluentValidation
 11///     accumulates rules added by both the base and derived constructors into the same rule set.
 12/// </summary>
 13public abstract class PaginatedQueryValidator<TQuery> : AbstractValidator<TQuery> where TQuery : BaseQuery
 14{
 15    /// <summary>
 16    ///     The upper bound on <c>PageSize</c>. Matches <see cref="BaseQuery" />'s own default of 100,
 17    ///     so a caller who never sets <c>PageSize</c> is always within bounds.
 18    /// </summary>
 19    protected const int MaxPageSize = 100;
 20
 21    /// <summary>
 22    ///     The last page number whose offset, <c>(PageNumber - 1) * PageSize</c>, still fits in an
 23    ///     <see cref="int" /> at the largest page size. The pagination helper computes that offset in
 24    ///     unchecked arithmetic, so a larger number wrapped to a negative OFFSET, which PostgreSQL
 25    ///     rejects — a 500 from nothing more than an absurd query string.
 26    /// </summary>
 27    public const int MaxPageNumber = int.MaxValue / MaxPageSize;
 28
 24129    protected PaginatedQueryValidator()
 30    {
 24131        RuleFor(query => query.PageNumber)
 24132            .InclusiveBetween(1, MaxPageNumber)
 24133            .WithMessage(PaginationMessages.InvalidPageNumber);
 34
 24135        RuleFor(query => query.PageSize)
 24136            .InclusiveBetween(1, MaxPageSize)
 24137            .WithMessage(PaginationMessages.InvalidPageSize);
 24138    }
 39}

Methods/Properties

.ctor()