🚑 Allow for regex without slashes for retro compat
This commit is contained in:
@@ -76,6 +76,6 @@ const parseValuePlaceholder = (
|
|||||||
return ''
|
return ''
|
||||||
case ComparisonOperators.MATCHES_REGEX:
|
case ComparisonOperators.MATCHES_REGEX:
|
||||||
case ComparisonOperators.NOT_MATCH_REGEX:
|
case ComparisonOperators.NOT_MATCH_REGEX:
|
||||||
return '^[0-9]+$'
|
return '/^[0-9]+$/'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ Example:
|
|||||||
|
|
||||||
- `/^hello$/` will match if the string is strictly equal to "hello".
|
- `/^hello$/` will match if the string is strictly equal to "hello".
|
||||||
- `/hello/` will match if the string contains "hello". Like "hello world".
|
- `/hello/` will match if the string contains "hello". Like "hello world".
|
||||||
|
- `/hello/i` will match if the string contains "hello" case-insensitive. Like "Hello world".
|
||||||
|
- `/[0-9]+/` will match if the string contains one or more digits. Like "123".
|
||||||
|
|
||||||
</ResponseField>
|
</ResponseField>
|
||||||
|
|
||||||
|
|||||||
@@ -176,9 +176,10 @@ const parseDateOrNumber = (value: string): number => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const preprocessRegex = (regex: string) => {
|
const preprocessRegex = (regex: string) => {
|
||||||
const match = regex.match(/^\/([^\/]+)\/([gimuy]*)$/)
|
const regexWithFlags = regex.match(/\/(.+)\/([gimuy]*)$/)
|
||||||
|
|
||||||
if (!match) return null
|
if (regexWithFlags)
|
||||||
|
return { pattern: regexWithFlags[1], flags: regexWithFlags[2] }
|
||||||
|
|
||||||
return { pattern: match[1], flags: match[2] }
|
return { pattern: regex }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user