compose
compose :: [ Function ] β†’ a β†’ Boolean
It's the very backbone of Deep Waters, it takes a list of validators
[validators][validators]
(functions that accept a value and return a boolean) and returns a new function that takes a value
vv
and evaluates whether
vv
is valid for all the validators in
[validators][validators]
.
isEmail.js
import compose from './compose';
import isString from './isString';
import matchesPattern from './matchesPattern';
​
const isEmail = compose(
isString,
matchesPattern(/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/),
);
​
export default isEmail;
Please note, compose removes all the duplicate validators
​
Copy link