UNPKG

524 BJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', {
4 value: true
5});
6exports.default = validatePattern;
7
8/**
9 * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
10 *
11 * This source code is licensed under the MIT license found in the
12 * LICENSE file in the root directory of this source tree.
13 */
14function validatePattern(pattern) {
15 if (pattern) {
16 try {
17 // eslint-disable-next-line no-new
18 new RegExp(pattern, 'i');
19 } catch {
20 return false;
21 }
22 }
23
24 return true;
25}