• 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

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
2✔
6
{
7
    public override bool IsValid()
8
    {
9
        var totalItems = fieldValue switch
2!
10
        {
2✔
11
            ICollection<TField> collection => collection.Count,
2✔
12
            _ => fieldValue.Count()
×
13
        };
2✔
14
        var totalDistinctItems = fieldValue.Distinct().Count();
2✔
15
        return totalDistinctItems == totalItems;
2✔
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