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

AndreuCodina / CrossValidation / 5956170496

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

Pull #79

github

web-flow
Merge 95af9735e 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.38 hits per line

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

81.82
/src/CrossValidation/Validators/CollectionValidators/UniqueItemsValidator.cs
1
using CrossValidation.Exceptions;
2

3
namespace CrossValidation.Validators.CollectionValidators;
4

5
public class UniqueItemsValidator<TField>(IEnumerable<TField> fieldValue) : Validator
3✔
6
{
7
    public override bool IsValid()
8
    {
9
        var totalItems = fieldValue switch
3!
10
        {
3✔
11
            ICollection<TField> collection => collection.Count,
3✔
12
            _ => fieldValue.Count()
×
13
        };
3✔
14
        var totalDistinctItems = fieldValue.Distinct().Count();
3✔
15
        return totalDistinctItems == totalItems;
3✔
16
    }
17

18
    public override BusinessException CreateException()
19
    {
20
        throw new CommonException.UniqueItemsException();
1✔
21
    }
22
}
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