filter-expressions
Version:
Basic array structure that can conditionally validate objects
21 lines (19 loc) • 436 B
JavaScript
const isValidExpression = expression => {
// Expressions are arrays
if (!Array.isArray(expression)) {
return false;
}
// Expressions should have more than 2 values
if (expression.length < 2) {
return false;
}
// Expressions start with a string in teh array
if (typeof expression[0] !== 'string') {
return false;
}
// Assume valid after checks
return true;
};
module.exports = {
isValidExpression
};