feat(engine): ♿️ Lowercase resiliency on "contains" operator
This commit is contained in:
@ -88,19 +88,22 @@ const executeCondition = (
|
|||||||
const executeComparison =
|
const executeComparison =
|
||||||
(variables: Variable[]) => (comparison: Comparison) => {
|
(variables: Variable[]) => (comparison: Comparison) => {
|
||||||
if (!comparison?.variableId) return false
|
if (!comparison?.variableId) return false
|
||||||
const inputValue =
|
const inputValue = (
|
||||||
variables.find((v) => v.id === comparison.variableId)?.value ?? ''
|
variables.find((v) => v.id === comparison.variableId)?.value ?? ''
|
||||||
const value = parseVariables(variables)(comparison.value)
|
)
|
||||||
|
.toString()
|
||||||
|
.trim()
|
||||||
|
const value = parseVariables(variables)(comparison.value).toString().trim()
|
||||||
if (isNotDefined(value)) return false
|
if (isNotDefined(value)) return false
|
||||||
switch (comparison.comparisonOperator) {
|
switch (comparison.comparisonOperator) {
|
||||||
case ComparisonOperators.CONTAINS: {
|
case ComparisonOperators.CONTAINS: {
|
||||||
return inputValue.toString().includes(value.toString())
|
return inputValue.toLowerCase().includes(value.toLowerCase())
|
||||||
}
|
}
|
||||||
case ComparisonOperators.EQUAL: {
|
case ComparisonOperators.EQUAL: {
|
||||||
return inputValue.toString() === value.toString()
|
return inputValue === value
|
||||||
}
|
}
|
||||||
case ComparisonOperators.NOT_EQUAL: {
|
case ComparisonOperators.NOT_EQUAL: {
|
||||||
return inputValue.toString() !== value.toString()
|
return inputValue !== value
|
||||||
}
|
}
|
||||||
case ComparisonOperators.GREATER: {
|
case ComparisonOperators.GREATER: {
|
||||||
return parseFloat(inputValue) >= parseFloat(value)
|
return parseFloat(inputValue) >= parseFloat(value)
|
||||||
|
Reference in New Issue
Block a user