Created
October 23, 2016 18:57
-
-
Save Killavus/1882c51353b01dae0e2caf1a08c64b19 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const reduceCompose = (f, g) => x => g(x, f(x)) | |
const reduceComposeArr = (...fns) => fns.reduce(reduceCompose, (x, y) => y) | |
const isNumber = (x, errors = {}) => Number.isNaN(parseInt(x, 10)) ? Object.assign({}, errors, { number: true }) : errors; | |
undefined | |
const length = (z) => (x, errors = {}) => (x && x.length < z) ? Object.assign({}, errors, { length: true }) : errors; | |
const presence = (x, errors = {}) => x === undefined ? Object.assign({}, errors, { presence: true }) : errors; | |
reduceComposeArr(presence, length(3), isNumber)('123') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment