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

AndreuCodina / CrossValidation / 5943551640

22 Aug 2023 08:09PM UTC coverage: 92.899% (+0.2%) from 92.715%
5943551640

Pull #76

github

web-flow
Merge eac55b431 into 39c781587
Pull Request #76: Add comparison validators

433 of 490 branches covered (88.37%)

Branch coverage included in aggregate %.

80 of 80 new or added lines in 12 files covered. (100.0%)

1451 of 1538 relevant lines covered (94.34%)

173.12 hits per line

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

71.43
/src/CrossValidation/Validators/StringValidators/LengthRangeValidator.cs
1
using CrossValidation.Exceptions;
2

3
namespace CrossValidation.Validators.StringValidators;
4

5
public class LengthRangeValidator(string fieldValue, int minimum, int maximum) : Validator
6✔
6
{
7
    public override bool IsValid()
8
    {
9
        if (minimum > maximum)
6!
10
        {
11
            throw new ArgumentException("The minimum length cannot be greater than the maximum length");
×
12
        }
13
        else if (maximum < minimum)
6!
14
        {
15
            throw new ArgumentException("The maximum length cannot be less than the minimum length");
×
16
        }
17

18
        return fieldValue.Length >= minimum
6✔
19
               && fieldValue.Length <= maximum;
6✔
20
    }
21

22
    public override BusinessException CreateException()
23
    {
24
        return new CommonException.LengthRangeException(minimum, maximum, fieldValue.Length);
3✔
25
    }
26
}
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