Skip to content

Commit b22971c

Browse files
author
Marco Franceschi
committed
feat: Included matchAny for regex operators
1 parent b40db40 commit b22971c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/rules-engine/operators/regex.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,16 @@
22
export default {
33
match: (a, b) => new RegExp(b).test(a),
44
mismatch: (a, b) => !new RegExp(b).test(a),
5+
matchAny: (a, b) => {
6+
if (Array.isArray(a)) {
7+
const result = a
8+
.map(value =>
9+
typeof value === 'string' ? !new RegExp(b).test(value) : undefined
10+
)
11+
.some(v => v)
12+
return result
13+
}
14+
15+
return false
16+
},
517
}

0 commit comments

Comments
 (0)