UNPKG

@stoplight/spectral

Version:

A flexible object linter with out of the box support for OpenAPI v2 and v3.

26 lines 766 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.pattern = (targetVal, opts) => { const results = []; if (!targetVal || typeof targetVal !== 'string') return results; const { match, notMatch } = opts; if (match) { const re = new RegExp(match); if (re.test(targetVal) !== true) { results.push({ message: `must match the pattern '${match}'`, }); } } if (notMatch) { const re = new RegExp(notMatch); if (re.test(targetVal) === true) { results.push({ message: `must not match the pattern '${notMatch}'`, }); } } return results; }; //# sourceMappingURL=pattern.js.map