mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-31 12:52:13 +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 = (
|
||||
pattern: string,
|
||||
customChecker?: (pattern: string) => boolean
|
||||
customChecker?: (pattern: any) => boolean
|
||||
): { isValid: boolean; regExp: RegExp } => {
|
||||
const regExp = new RegExp(pattern);
|
||||
const { source } = regExp;
|
||||
const isValid = source !== emptyRegexSource;
|
||||
const isValid = !!pattern && source !== emptyRegexSource;
|
||||
|
||||
if (isValid && customChecker && customChecker(pattern)) {
|
||||
return { isValid, regExp };
|
||||
|
Loading…
x
Reference in New Issue
Block a user