3 Commits
Author SHA1 Message Date
dualfroz 8542a160cf Describe this repository 2026-10-22 21:01:59 +02:00
dualfroz 81309656cb fix: reject inverted range when comparer returns negative other than -1
RangeValidator's constructor guarded against an inverted range with
comparer.Compare(to, from) == -1. The IComparer<T>/IComparable<T> contract
only guarantees the sign of the result, not the magnitude, so the guard
silently failed for comparers returning other negatives, e.g. char.CompareTo
('a'.CompareTo('c') == -2) or custom comparers that return x - y. This let
InclusiveBetween('c', 'a') build a validator that can never pass instead of
throwing, unlike the int case which happens to return -1.

Compare against < 0 to honor the comparer contract. Add char-bound throw
tests to the inclusive and exclusive between suites.
2026-09-02 10:59:11 +02:00
dualfroz e9c920f846 fix: reject inverted range when comparer returns negative other than -1
RangeValidator's constructor guarded against an inverted range with
comparer.Compare(to, from) == -1. The IComparer<T>/IComparable<T> contract
only guarantees the sign of the result, not the magnitude, so the guard
silently failed for comparers returning other negatives, e.g. char.CompareTo
('a'.CompareTo('c') == -2) or custom comparers that return x - y. This let
InclusiveBetween('c', 'a') build a validator that can never pass instead of
throwing, unlike the int case which happens to return -1.

Compare against < 0 to honor the comparer contract. Add char-bound throw
tests to the inclusive and exclusive between suites.
2026-09-06 01:20:01 +02:00