Upstream FluentValidation/FluentValidation state of the touched files before 9bbcc68876
This commit is contained in:
1 parent
e9c920f846
commit
d49580c67a
3 files changed
+1
-14
No files matched your search
@@ -127,12 +127,6 @@ public class ExclusiveBetweenValidatorTests {
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => RangeValidatorFactory.CreateExclusiveBetween<Person, string>("ccc", "aaa"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void When_the_to_is_smaller_than_the_from_then_the_validator_should_throw_for_chars() {
|
||||
// char.CompareTo returns the difference ('a' vs 'c' is -2), not just -1.
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => RangeValidatorFactory.CreateExclusiveBetween<Person, char>('c', 'a'));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void When_the_validator_fails_the_error_message_should_be_set_for_strings() {
|
||||
var validator = new TestValidator(v => v.RuleFor(x => x.Surname).ExclusiveBetween("bbb", "zzz"));
|
||||
|
||||
@@ -122,12 +122,6 @@ public class InclusiveBetweenValidatorTests {
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => RangeValidatorFactory.CreateInclusiveBetween<Person, string>("ccc", "aaa"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void When_the_to_is_smaller_than_the_from_then_the_validator_should_throw_for_chars() {
|
||||
// char.CompareTo returns the difference ('a' vs 'c' is -2), not just -1.
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => RangeValidatorFactory.CreateInclusiveBetween<Person, char>('c', 'a'));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void When_the_validator_fails_the_error_message_should_be_set_for_strings() {
|
||||
var validator = new TestValidator(v => v.RuleFor(x => x.Surname).InclusiveBetween("bbb", "zzz"));
|
||||
|
||||
@@ -34,8 +34,7 @@ public abstract class RangeValidator<T, TProperty> : PropertyValidator<T, TPrope
|
||||
|
||||
_explicitComparer = comparer;
|
||||
|
||||
// IComparer<T> only guarantees the sign, not the magnitude.
|
||||
if (comparer.Compare(to, from) < 0) {
|
||||
if (comparer.Compare(to, from) == -1) {
|
||||
throw new ArgumentOutOfRangeException(nameof(to), "To should be larger than from.");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user