blast from my programming past
Despite all my attempts to convince myself that it was a bad idea and not needed (I mean, I even tried to solve the problem with XML), I have found myself working on a schema and data validation system.
Iβll write more about it when itβs more done.
In the meantime, I needed, in several places, both in the schemata and in my internal code, to quickly say βgiven these minimum and maximum values, which may or may not be exclusive, construct a validator.β
I was slowly slogging through this, dreading the growing cross-product of possible combinations, when I realized that I made this simple five years ago, and now I could reap the benefits β becoming, once again, probably the only person to use Number::Tolerant.
push @tolerances, Number::Tolerant->new($arg->{min} => 'or_more')
if defined $arg->{min};
push @tolerances, ... if ...;
my $tol = reduce { $a & $b } @tolerances;
return sub { $_[0] == $tol };
Thanks, younger me! For once you didnβt set me up for more obnoxious work.