This may be preferable to adding :min or :max options for such validations. The problem is that use of join when displaying the enumeration when the validation fails, as Range#join does not exist.
Options to do this include:
Implement Range#join. I personally don't like this option, as we could end up allocating large arrays for no real gain, which would clutter the output.
Improve the way the enumeration is printed when you specify a value outside the enumeration. Instead of relying on join, perhaps detect that it is a Range and print it out in a friendlier way that clearly indicates the min and max values of that range.
I'm happy to submit a PR if I can get some guidance on which option would be preferred or if there is another proposed solution.
There are cases, such as numerics, where you may want to enforce that an option's value is within an acceptable range of values.
This may be preferable to adding
:min
or:max
options for such validations. The problem is that use ofjoin
when displaying the enumeration when the validation fails, asRange#join
does not exist.Options to do this include:
Range#join
. I personally don't like this option, as we could end up allocating large arrays for no real gain, which would clutter the output.join
, perhaps detect that it is a Range and print it out in a friendlier way that clearly indicates the min and max values of that range.I'm happy to submit a PR if I can get some guidance on which option would be preferred or if there is another proposed solution.