mirror of
https://github.com/datahub-project/datahub.git
synced 2025-09-02 22:03:11 +00:00
fixes null pattern in validateRegExp util function
This commit is contained in:
parent
f9253623df
commit
ff41815f63
@ -13,11 +13,11 @@ const emptyRegexSource = '(?:)';
|
|||||||
*/
|
*/
|
||||||
const validateRegExp = (
|
const validateRegExp = (
|
||||||
pattern: string,
|
pattern: string,
|
||||||
customChecker?: (pattern: string) => boolean
|
customChecker?: (pattern: any) => boolean
|
||||||
): { isValid: boolean; regExp: RegExp } => {
|
): { isValid: boolean; regExp: RegExp } => {
|
||||||
const regExp = new RegExp(pattern);
|
const regExp = new RegExp(pattern);
|
||||||
const { source } = regExp;
|
const { source } = regExp;
|
||||||
const isValid = source !== emptyRegexSource;
|
const isValid = !!pattern && source !== emptyRegexSource;
|
||||||
|
|
||||||
if (isValid && customChecker && customChecker(pattern)) {
|
if (isValid && customChecker && customChecker(pattern)) {
|
||||||
return { isValid, regExp };
|
return { isValid, regExp };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user