UNPKG

766 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.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//# sourceMappingURL=pattern.js.map
\No newline at end of file