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

AndreuCodina / CrossValidation / 5956069759

23 Aug 2023 08:19PM UTC coverage: 93.071% (-0.1%) from 93.194%
5956069759

Pull #79

github

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

442 of 500 branches covered (88.4%)

Branch coverage included in aggregate %.

46 of 46 new or added lines in 5 files covered. (100.0%)

1519 of 1607 relevant lines covered (94.52%)

168.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

© 2025 Coveralls, Inc