fix: Evaluate multiple logic's with | and &. (#301)
parent
c7f168c4a8
commit
ecf2de8b19
|
@ -27,9 +27,8 @@ class evaluator {
|
||||||
objectToEvaluate.logic.trim() === '') {
|
objectToEvaluate.logic.trim() === '') {
|
||||||
return defaultUndefined
|
return defaultUndefined
|
||||||
}
|
}
|
||||||
let st = objectToEvaluate.logic.trim().replace('\n', '')
|
const st = objectToEvaluate.logic.trim().replace('\n', '')
|
||||||
st = st.replace('|', '~')
|
const expr = /(\||&)/
|
||||||
const expr = /(~|&)/
|
|
||||||
const stList = st.split(expr)
|
const stList = st.split(expr)
|
||||||
const it = stList.length
|
const it = stList.length
|
||||||
|
|
||||||
|
@ -41,7 +40,7 @@ class evaluator {
|
||||||
let retValue = null
|
let retValue = null
|
||||||
let logOp = ''
|
let logOp = ''
|
||||||
stList.forEach(function(element) {
|
stList.forEach(function(element) {
|
||||||
if (element === '~' || element === '&') {
|
if (element.trim() === '|' || element.trim() === '&') {
|
||||||
logOp = element
|
logOp = element
|
||||||
} else if (retValue === null) {
|
} else if (retValue === null) {
|
||||||
retValue = evaluator.evaluateLogicTuples({
|
retValue = evaluator.evaluateLogicTuples({
|
||||||
|
@ -49,12 +48,12 @@ class evaluator {
|
||||||
conditional: element
|
conditional: element
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
if (logOp === '&' && logOp !== '') {
|
if (logOp.trim() === '&') {
|
||||||
retValue = retValue & evaluator.evaluateLogicTuples({
|
retValue = retValue & evaluator.evaluateLogicTuples({
|
||||||
...objectToEvaluate,
|
...objectToEvaluate,
|
||||||
conditional: element
|
conditional: element
|
||||||
})
|
})
|
||||||
} else if (logOp === '~' && logOp !== '') {
|
} else if (logOp.trim() === '|') {
|
||||||
retValue = retValue | evaluator.evaluateLogicTuples({
|
retValue = retValue | evaluator.evaluateLogicTuples({
|
||||||
...objectToEvaluate,
|
...objectToEvaluate,
|
||||||
conditional: element
|
conditional: element
|
||||||
|
@ -84,7 +83,7 @@ class evaluator {
|
||||||
if (logic === undefined) {
|
if (logic === undefined) {
|
||||||
return _defaultUndefined
|
return _defaultUndefined
|
||||||
}
|
}
|
||||||
let expr = /^(['"@#$a-zA-Z0-9\-_\s]){0,}((<>|<=|<|=|>=|>|!=|!|\^){1,2})([\s"'@#$a-zA-Z0-9\-_]){0,}$/i
|
let expr = /^(['"@#$a-zA-Z0-9\-_\s]){0,}((<>|<=|<|==|=|>=|>|!=|!|\^){1,2})([\s"'@#$a-zA-Z0-9\-_]){0,}$/i
|
||||||
let st = expr.test(logic)
|
let st = expr.test(logic)
|
||||||
|
|
||||||
if (!st) {
|
if (!st) {
|
||||||
|
@ -92,7 +91,7 @@ class evaluator {
|
||||||
return _defaultUndefined
|
return _defaultUndefined
|
||||||
}
|
}
|
||||||
|
|
||||||
expr = /(<>|<=|<|=|>=|>|!=|!|\^){1,2}/i
|
expr = /(<>|<=|<|==|=|>=|>|!=|!|\^){1,2}/i
|
||||||
st = logic.split(expr)
|
st = logic.split(expr)
|
||||||
|
|
||||||
// First Part (or column name)
|
// First Part (or column name)
|
||||||
|
|
Loading…
Reference in New Issue