• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

AndreuCodina / CrossValidation / 5955891945

23 Aug 2023 08:00PM UTC coverage: 93.12% (-0.07%) from 93.194%
5955891945

Pull #79

github

web-flow
Merge a9a996ec2 into e1c625139
Pull Request #79: Add collection validators

441 of 498 branches covered (88.55%)

Branch coverage included in aggregate %.

34 of 34 new or added lines in 4 files covered. (100.0%)

1508 of 1595 relevant lines covered (94.55%)

169.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.0
/src/CrossValidation/Validators/CollectionValidators/MinimumItemsValidator.cs
1
using CrossValidation.Exceptions;
2

3
namespace CrossValidation.Validators.CollectionValidators;
4

5
public class MinimumItemsValidator<TField>(IEnumerable<TField> fieldValue, int minimumItems) : Validator
3✔
6
{
7
    private int _totalItems;
8

9
    public override bool IsValid()
10
    {
11
        _totalItems = fieldValue switch
3!
12
        {
3✔
13
            ICollection<TField> collection => collection.Count,
3✔
14
            _ => fieldValue.Count()
×
15
        };
3✔
16
        return _totalItems >= minimumItems;
3✔
17
    }
18

19
    public override BusinessException CreateException()
20
    {
21
        throw new CommonException.MinimumItemsException(minimumItems, _totalItems);
1✔
22
    }
23
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc