Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions libraries/adaptive-expressions/src/builtinFunctions/isMatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,10 @@ export class IsMatch extends ExpressionEvaluator {
*/
private static evaluator(): EvaluateExpressionDelegate {
return FunctionUtils.applyWithError((args: any[]): any => {
let value = false;
let error: string;
if (args[0] === undefined || args[0] === '') {
value = false;
error = 'regular expression is empty.';
} else {
const regex: RegExp = CommonRegex.CreateRegex(args[1].toString());
value = regex.test(args[0].toString());
}

return { value, error };
const regex: RegExp = CommonRegex.CreateRegex(args[1].toString());
const inputString = args[0] ? args[0].toString() : '';
const value = regex.test(inputString);
return { value, undefined };
}, FunctionUtils.verifyStringOrNull);
}

Expand Down
2 changes: 2 additions & 0 deletions libraries/adaptive-expressions/tests/expressionParser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,8 @@ const testCases = [
['isMatch("1", "\\\\d{1}")', true], // "\d" (match [0-9])
['isMatch("12.5", "[0-9]+(\\\\.5)")', true], // "\." (match .)
['isMatch("12x5", "[0-9]+(\\\\.5)")', false], // "\." (match .)
["isMatch('', '[0-9]')", false], // empty string
["isMatch(nullObj, '[0-9]')", false], // null object
],
},
{
Expand Down