2
0

🐛 (condition) Greater and Less should compare list length when possible

This commit is contained in:
Baptiste Arnaud
2023-04-20 14:54:56 +02:00
parent 4d1fe4c1de
commit c77b8e7548
4 changed files with 24 additions and 18 deletions

View File

@@ -63,24 +63,24 @@ const executeComparison =
return compare((a, b) => a !== b, inputValue, value)
}
case ComparisonOperators.GREATER: {
return compare(
(a, b) =>
isDefined(a) && isDefined(b)
? parseFloat(a) > parseFloat(b)
: false,
inputValue,
value
)
if (typeof inputValue === 'string') {
if (typeof value === 'string')
return parseFloat(inputValue) > parseFloat(value)
return parseFloat(inputValue) > value.length
}
if (typeof value === 'string')
return inputValue.length > parseFloat(value)
return inputValue.length > value.length
}
case ComparisonOperators.LESS: {
return compare(
(a, b) =>
isDefined(a) && isDefined(b)
? parseFloat(a) < parseFloat(b)
: false,
inputValue,
value
)
if (typeof inputValue === 'string') {
if (typeof value === 'string')
return parseFloat(inputValue) < parseFloat(value)
return parseFloat(inputValue) < value.length
}
if (typeof value === 'string')
return inputValue.length < parseFloat(value)
return inputValue.length < value.length
}
case ComparisonOperators.IS_SET: {
return isDefined(inputValue) && inputValue.length > 0