between
between :: Number → Number → a → Boolean
Takes a two numbers, min and max, and return a new function evaluating whether the received value is of included between min and max. (the one previously defined). The evaluation is not inclusive.
The between validator is a curried function
import between from 'deep-waters/between';
const isTeen = between(10)(19);
isTeen(17) // → true
isTeen(22); // → false
isTeen(7); // → false
Please note, between returned functions does not evaluate if the received values are of type integer or float. A good improvement for the isTeen validator from the example above could be the following:
import compose from 'deep-waters/compose';
import between from 'deep-waters/between';
const isTeen = compose(Number.isInteger, between(10)(19));
Copy link