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 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 396x 144x 144x 396x 6x 6x 380x 68x 68x 368x 5x 5x 368x 3x 3x 368x 5x 5x 396x 24x 24x 396x 16x 16x 368x 20x 12x 12x 20x 4x 4x 4x 4x 396x 66x 66x 39x 39x 1x 1x | const stringify = require('../../../handlers/basic/stringify'); /** * Checks value with checkValue depending on operator * @param {Array} value - input value to check * @param {String} operator - operator * @param {Any} checkValue - other input value to check agains value * @returns {Boolean} - true if it complies, false otherwise */ // eslint-disable-next-line complexity const logicalValidator = (value, operator, checkValue, element) => { if (operator === '=') { return (stringify(value) === stringify(checkValue)); } if (operator === '!=') { return (stringify(value) !== stringify(checkValue)); } if (operator === '>=') { return (value >= checkValue); } if (operator === '>') { return (value > checkValue); } if (operator === '<=') { return (value <= checkValue); } if (operator === '<') { return (value < checkValue); } if (operator === '∈' || operator === '@') { return (checkValue.indexOf(value) > -1); } if (operator === '∉' || operator === '!@') { return (checkValue.indexOf(value) === -1); } if (operator === '?') { if (checkValue.regex) { return checkValue.regex.test(value); } if (value.regex) { return value.regex.test(checkValue); } return false; } if (value && value.function) { return value.function(element); } return !!value; }; module.exports = logicalValidator; |