2
0

(condition) Add regex comparison item

This commit is contained in:
Baptiste Arnaud
2023-08-01 08:20:16 +02:00
parent 14c3d95b8a
commit aa9f5bc732
6 changed files with 81 additions and 13 deletions

View File

@ -89,6 +89,20 @@ const executeComparison =
}
return compare(endsWith, inputValue, value)
}
case ComparisonOperators.MATCHES_REGEX: {
const matchesRegex = (a: string | null, b: string | null) => {
if (b === '' || !b || !a) return false
return new RegExp(b).test(a)
}
return compare(matchesRegex, inputValue, value, 'some')
}
case ComparisonOperators.NOT_MATCH_REGEX: {
const matchesRegex = (a: string | null, b: string | null) => {
if (b === '' || !b || !a) return false
return !new RegExp(b).test(a)
}
return compare(matchesRegex, inputValue, value)
}
}
}