How to use the matcher function in matcher

To help you get started, we’ve selected a few matcher examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github swagger-api / swagger-editor / src / plugins / validate-json-schema / semantic-validators / validators / walker.js View on Github external
function walk(value, path) {
    let curr = path[path.length - 1]

    if(value === null) {
      return null
    }

    ///// Restricted $refs

    if(curr === "$ref") {
      let refBlacklist = getRefPatternBlacklist(path) || []
      let matches = match([value], refBlacklist)

      let humanFriendlyRefBlacklist = refBlacklist
        .map(val => `"${val}"`)
        .join(", ")

      if(refBlacklist && refBlacklist.length && matches.length) {
        // Assertation 1
        errors.push({
          path,
          message: `${path[path.length - 2]} $refs cannot match any of the following: ${humanFriendlyRefBlacklist}`
        })
      }
    }

    if(typeof value !== "object") {
      return null
github tensult / role-acl / src / utils / common.ts View on Github external
public static anyMatch(strings: string | string[], patterns: string | string[]): boolean {
        const stringArray = ArrayUtil.toStringArray(strings);
        const patternArray = ArrayUtil.toStringArray(patterns);
        return Matcher(stringArray, patternArray).length !== 0;
    }