All files / create-validator index.js

100% Statements 8/8
100% Branches 6/6
100% Functions 3/3
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 1234x 105x 105x   105x 47x 47x     105x    
export default definition => (message, ...options) => (value, fields) => {
    let error = typeof message === 'function' ? message(value, ...options) : message;
    let isValid = false;
 
    if (options.length ? definition(value, ...options, fields) : definition(value, fields)) {
        isValid = true;
        error = '';
    }
 
    return { isValid, error };
}