/*
for use in Other TAFs, before they attempt backend validation of
425394
public static Counter isDeniedID(String identity) {
		if(deniedID!=null) {
			return deniedID.get(identity);
		}
		return null;
	}
964236
function(model, attrs, validatedAttrs) {
      var error,
          invalidAttrs = {},
          isValid = true,
          computed = _.clone(attrs);

      _.each(validatedAttrs, function(val, attr) {
        error = validateAttrWithOpenArray(model, attr, val, computed);
        if (error) {
          invalidAttrs[attr] = error;
          isValid = false;
        }
      });

      return {
        invalidAttrs: invalidAttrs,
        isValid: isValid
      };
    }
901146
function matchAllowedLocalAction(text, allowedActions, actionPatterns) {
  const matched = matchAction(text, allowedActions, actionPatterns);

  if (matched) {
    // back command doesn't require a target
    if (matched.action === actions.back) {
      delete matched.objectName;
      return matched;
    }

    // Match returns empty string if command doesn't capture any objects
    if (matched.objectName === '') {
      // TODO: This section looks sketchy. Need to refactor
      if (allowedActions[matched.action].length == 1) {
        matched.object = allowedActions[matched.action][0];
      }
    } else {
      allowedActions[matched.action].forEach(object => {
        object.names.forEach(name => {
          if (name === matched.objectName) {
            matched.object = object;
          }
        })
      });
    }

    if (matched.action && matched.object) {
      delete matched.objectName;
      return matched;
    }
  }

  return undefined;
}
654537
static function validate($schema, $value, $helper = NULL) {
    foreach (self::parseConstraints($schema) as $c) {  // The constraints are in a numeric array as the order matters.
      $constraint = key($c);
      $params     = $c[$constraint];

      if (self::isBlank($value) && ! preg_match('/require|notblank/i', $constraint)) continue; // Only *require* validators should check blank values.

      $value = self::constrain($value, $constraint, self::parseParams($params, $schema), $helper);
    }

    return $value;
  }
1067798
def validate(options):
        
        try:
            if options.backends.index('modelinstance') > options.backends.index('model'):
                raise Exception("Metadata backend 'modelinstance' must come before 'model' backend")
        except ValueError:
            raise Exception("Metadata backend 'modelinstance' must be installed in order to use 'model' backend")
1086598
function validateParamsPresent(expectedKeys, params) {
  params = params || {};
  var paramKeys = _.keys(params);
  return _.first(_.difference(expectedKeys, _.intersection(paramKeys, expectedKeys)));
}
639091
function(tokenStr) {
            if (typeof tokenStr !== 'string') {
                return null;
            }
            var token = tokenCache[tokenStr];
            if (token !== undefined) {
                return token;
            } else {
                try {
                    token = tokens.validate(tokenStr, trustedPubKey);
                    tokenCache[tokenStr] = token;
                    return token;
                } catch (err) {
                    // did not validate, cache negative result.
                    tokenCache[tokenStr] = null;
                    return null;
                }
            }
        }
613729
function validateFileset(fileset, setter) {
    if (Array.isArray(fileset)) {
        async.each(fileset, function(path, callback) {
            if (typeof path === 'string') {
                callback();
            } else {
                callback(util.format('Invalid path: %s', path));
            }
        }, function(err) {
            if (err) {
                console.log(chalk.red(err));
            } else {
                setter(fileset);
            }
        });
    } else {
        console.log(chalk.red('Fileset is not an array: %j'), fileset);
    }
}
611774
public TafResp validate(Taf.LifeForm reading, HttpServletRequest req, HttpServletResponse resp) {
		// See if Request implements BasicCred (aka CadiWrap or other), and if User/Pass has already been set separately
		if(req instanceof BasicCred) {
			BasicCred bc = (BasicCred)req;
			if(bc.getUser()!=null) { // CadiWrap, if set, makes sure User & Password are both valid, or both null
				if(DenialOfServiceTaf.isDeniedID(bc.getUser())!=null) {
					return DenialOfServiceTaf.respDenyID(access,bc.getUser());
				}
				CachedBasicPrincipal bp = new CachedBasicPrincipal(this,bc,realm,timeToLive);
				// ONLY FOR Last Ditch DEBUGGING... 
				// access.log(Level.WARN,bp.getName() + ":" + new String(bp.getCred()));
				if(rbac.validate(bp.getName(),Type.PASSWORD,bp.getCred())) {
					return new BasicHttpTafResp(access,bp,bp.getName()+" authenticated by password",RESP.IS_AUTHENTICATED,resp,realm,false);
				} else {
					//TODO may need timed retries in a given time period
					return new BasicHttpTafResp(access,null,buildMsg(bp,req,"User/Pass combo invalid for ",bc.getUser()), 
							RESP.TRY_AUTHENTICATING,resp,realm,true);
				}
			}
		}
		// Get User/Password from Authorization Header value
		String authz = req.getHeader("Authorization");
		if(authz != null && authz.startsWith("Basic ")) {
			if(warn&&!req.isSecure()) {
				access.log(Level.WARN,"WARNING! BasicAuth has been used over an insecure channel");
			}
			try {
				CachedBasicPrincipal ba = new CachedBasicPrincipal(this,authz,realm,timeToLive);
				if(DenialOfServiceTaf.isDeniedID(ba.getName())!=null) {
					return DenialOfServiceTaf.respDenyID(access,ba.getName());
				}

				// ONLY FOR Last Ditch DEBUGGING... 
				// access.log(Level.WARN,ba.getName() + ":" + new String(ba.getCred()));
				if(rbac.validate(ba.getName(), Type.PASSWORD, ba.getCred())) {
					return new BasicHttpTafResp(access,ba, ba.getName()+" authenticated by BasicAuth password",RESP.IS_AUTHENTICATED,resp,realm,false);
				} else {
					//TODO may need timed retries in a given time period
					return new BasicHttpTafResp(access,null,buildMsg(ba,req,"User/Pass combo invalid"), 
							RESP.TRY_AUTHENTICATING,resp,realm,true);
				}
			} catch (IOException e) {
				String msg = buildMsg(null,req,"Failed HTTP Basic Authorization (", e.getMessage(), ')');
				access.log(Level.INFO,msg);
				return new BasicHttpTafResp(access,null,msg, RESP.TRY_AUTHENTICATING, resp, realm,true);
			}
		}
		return new BasicHttpTafResp(access,null,"Requesting HTTP Basic Authorization",RESP.TRY_AUTHENTICATING,resp,realm,false);
	}
481427
function isValidRegExp(context: ParserContext): boolean {
  const previousNonWsToken = context.token(context.count() - 1);

  let previousToken;
  if (context.defaultData.text !== "") {
    previousToken = context.createToken("default", context.defaultData.text);
  } else {
    previousToken = previousNonWsToken;
    // Okay if there is no previous token.
    if (!previousToken) return true;
  }

  // Since JavaScript doesn't require statement terminators, if the previous
  // token was whitespace and contained a newline, then we're good.
  if (
    previousToken.name === "default" &&
    previousToken.value.indexOf("\n") >= 0
  )
    return true;

  // In these case the / stands for division.
  if (util.contains(["keyword", "ident", "number"], previousNonWsToken.name))
    return false;

  if (
    previousNonWsToken.name === "punctuation" &&
    !util.contains(["(", "{", "[", ",", ";"], previousNonWsToken.value)
  )
    return false;

  return true;
}
1198969
function prepareArgsForEncode (aci, params) {
  if (!aci) return params
  // Validation
  const validation = aci.arguments
    .map(
      ({ type }, i) =>
        validate(type, params[i])
          ? `Argument index: ${i}, value: [${params[i]}] must be of type [${type}]`
          : false
    ).filter(e => e)
  if (validation.length) throw new Error('Validation error: ' + JSON.stringify(validation))

  return aci.arguments.map(({ type }, i) => transform(type, params[i]))
}
860774
function validateAndCbBackend (instance, urlPort, cb) {
  var backendUrl = instance.dockerUrlForPort(urlPort);
  var err = validateContainer(instance.attrs.container);
  if (err) {
    return cb(err); }
  if (!backendUrl) {
    err = Boom.create(400, 'port not exposed', urlPort);
    return cb(err);
  }

  cb(null, backendUrl);
}
187127
async function validateOptions(options) {
  // Check that input glob was passed
  if (!options.paths.length) {
    throw new ValidationError('No paths specified')
  }

  // Check that output path was passed
  if (!options.outputDir) {
    throw new ValidationError('Please specify an output directory with -o or --output')
  }

  // Check that the existance of output path
  if (!await fsAsync.exists(options.outputDir)) {
    throw new ValidationError('Output directory doesn\'t exist')
  }

  // Check that output path is a directory
  const outStat = await fsAsync.stat(options.outputDir)
  if (!outStat.isDirectory()) {
    throw new ValidationError('Output path must be a directory')
  }

  // Check existance of CSS template (If set)
  if (options.cssTemplate && !await fsAsync.exists(options.cssTemplate)) {
    throw new ValidationError('CSS template not found')
  }

  // Check existance of HTML template (If set)
  if (options.htmlTemplate && !await fsAsync.exists(options.htmlTemplate)) {
    throw new ValidationError('HTML template not found')
  }

  // Validate codepoints file if passed
  if (options.codepoints) {
    if (!await fsAsync.exists(options.codepoints)) {
      throw new ValidationError(`Cannot find json file @ ${options.codepoints}!`)
    }

    const codepointsStat = await fsAsync.stat(options.codepoints)
    if (!codepointsStat.isFile() || path.extname(options.codepoints) !== '.json') {
      throw new ValidationError([
        'Codepoints file must be JSON',
        `${options.codepoints} is not a valid file.`
      ].join(' '))
    }
  }
}
57010
function validateData(data, schema, fn) {
        debug('Schema:', schema);
        debug('Data:', data);

        if (!tv4.validate(data, schema)) {
            return fn(tv4.error);
        }

        return fn(null, true);
    }
625384
function validateParams(dataSources, cb) {
  dataSources = _.map(dataSources, function(dataSourceUpdateData) {
    var failed = validate(dataSourceUpdateData).has(CONSTANTS.DATA_SOURCE_ID);

    if (failed) {
      dataSourceUpdateData.error = buildErrorResponse({error: new Error("Invalid Parameters For Updating Data Source Data Cache"), code: ERROR_CODES.FH_FORMS_INVALID_PARAMETERS});
    }

    if (!misc.checkId(dataSourceUpdateData._id)) {
      dataSourceUpdateData.error = buildErrorResponse({error: new Error("Invalid ID Paramter " + dataSourceUpdateData._id), code: ERROR_CODES.FH_FORMS_INVALID_PARAMETERS});
    }

    return dataSourceUpdateData;
  });

  //Filter out any data sources with invalid parameters.

  cb(undefined, dataSources);
}
505860
function(validationParameters) {
        var i = 0,
            j = 0;

        // We need to loop through each of the "extra parameters" and furthur split the `parameters` if need be.
        for (; i < validationParameters.length; i++) {
            // Check to see if we have third level "parameters" that will be transformed into an array for specific
            // validation methods.  i.e:  not_in:foo,bar,baz.
            if (validationParameters[i].contains(",")) {
                validationParameters[i] = validationParameters[i].split(",");

                // Since there was third level "parameters" we will go ahead and loop through each of the elements and
                // trim away any whitespace and convert falsey or truthy values to their boolean representations.
                for (; j < validationParameters[i].length; j++) {
                    validationParameters[i][j] = this.utils.convertStringToBoolean(validationParameters[i][j].trim());
                }
            } else {
                // Trim any whitespace and convert falsy or truthy values to their boolean representations
                validationParameters[i] = this.utils.convertStringToBoolean(validationParameters[i].trim());
            }
        }

        return validationParameters;
    }
156385
function validate(key) {
        var type = getType(key);
        if (type === "array") {
            for (var i = 0; i < key.length; i++) {
                validate(key[i]);
            }
        }
        else if (!types[type] || (type !== "string" && isNaN(key))) {
            throw idbModules.util.createDOMException("DataError", "Not a valid key");
        }
    }