1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.pattern = (targetVal, opts) => {
|
4 | const results = [];
|
5 | if (!targetVal || typeof targetVal !== 'string')
|
6 | return results;
|
7 | const { match, notMatch } = opts;
|
8 | if (match) {
|
9 | const re = new RegExp(match);
|
10 | if (re.test(targetVal) !== true) {
|
11 | results.push({
|
12 | message: `must match the pattern '${match}'`,
|
13 | });
|
14 | }
|
15 | }
|
16 | if (notMatch) {
|
17 | const re = new RegExp(notMatch);
|
18 | if (re.test(targetVal) === true) {
|
19 | results.push({
|
20 | message: `must not match the pattern '${notMatch}'`,
|
21 | });
|
22 | }
|
23 | }
|
24 | return results;
|
25 | };
|
26 |
|
\ | No newline at end of file |