/* ---------------------- /*    Helper functions /* ---------------------- 
function valid_errors(Array [errors])
Determines if JSHint gave valid errors.

[errors]: list of errors JSHint has generated.
978540
function valid_errors(errors) {

  /**
   *  Return false if [errors] is empty or if it isn't a non-empty array.
   */

  if (! errors) {
    return false;
  } else {
    if (! (errors instanceof Array)) {
      return false;
    } else {
      if (errors.length === 0) {
        return false;
      }
    }
  }

  return true;

}
202135
function validate() {
  const target = this._obj;

  isValidation(target);
  this.assert(_.has(target, 'error') && null === target.error,
      '#{this} should validate but does not because '+getErrorMessages(target),
      '#{this} should not validate but it does'
  );
}
364619
function areSelectorsValid(selectors, token) {
	return lodash.every(selectors, function(selector) {
		if (lodash.isRegExp(token)) {
			return token.test(lodash.trim(selector));
		} else {
			return lodash.startsWith(lodash.trim(selector), token);
		}
	});
}
625610
function validateOptsProperties(opts, validProperties) {
  var validProps = ensureVector(validProperties);
  var allOpts = jd.vector(Object.keys(opts), 'string');
  var invalidOpts = allOpts.s(allOpts.isIn(validProps).not());
  if (invalidOpts.size() > 0) {
    throw new Error('invalid properties found in "opts": ' +
      invalidOpts.strJoin(', '));
  }
}
196866
function(errors) {
			//!steal-remove-start
			if (process.env.NODE_ENV !== 'production') {
				clearTimeout(asyncTimer);
			}
			//!steal-remove-end

			var stub = error && error.call(self, errors);
			// if 'validations' is on the page it will trigger
			// the error itself and we dont want to trigger
			// the event twice. :)
			if (stub !== false) {
				mapEventsMixin.dispatch.call(self, 'error', [ prop, errors ], true);
			}
			return false;
		}
803341
function formatWebErrors(errors) {
    let errs = {};
    if (errors && errors.constructor == Array) {
        errors.forEach(function(item) {
            if (!errs[item.param]) errs[item.param] = [];
            errs[item.param].push(item.msg);
        });
    }
    return errs;
}
62411
function callback(err, hasError) {

    if (err !== null) {
        console.log(chalk.red('Error running JSHint over project: %j\n'), err);
    }

    if (hasError) {
        console.log(chalk.blue('\nSummary\n=======\n'));
        for (var errorCode in errors) {
            if (errors.hasOwnProperty(errorCode)) {
                displaySummary(errorCode);
            }
        }

        console.log('');

        if (totalErrors > 1) {
            console.log(chalk.red('Found %d errors.\n'), totalErrors);
        } else {
            console.log(chalk.red('Found 1 error.\n'));
        }
    } else {
        console.log(chalk.green('No JSHint errors found.\n'));
    }
}
1184874
function validate(ast) {
    if (!ast || !ast.inParams || !ast.tasks || !ast.outTask) return [AST_IS_OBJECT];
    var errors = [];
    errors = errors.concat(validateInParams(ast.inParams));
    errors = errors.concat(validateTasks(ast.tasks));
    errors = errors.concat(validateTaskNamesUnique(ast.tasks));
    errors = errors.concat(taskUtil.validateOutTask(ast.outTask));
    errors = errors.concat(validateLocals(ast.locals));
    if (errors.length === 0) { // if no errors do additional validation
      if (ast.outTask.type !== 'finalcbFirst') errors = errors.concat(validateOuputsUnique(ast.tasks));
      errors = errors.concat(taskUtil.validateLocalFunctions(ast.inParams, ast.tasks, ast.locals));
      errors = errors.concat(validateNoMissingNames(ast));
    }
    return errors;
  }
322593
function validateForm() {

            var isValid = isEmpty(errors);

            formData = {};

            $.each(
                node.find('input:not([type="submit"]), select, textarea').not(':disabled'),
                function(index, input) {

                    input = $(input);

                    var value = _getInputValue(input[0]),
                        inputName = input.attr('name');

                    if (inputName) {
                        if (/\[]$/.test(inputName)) {
                            inputName = inputName.replace(/\[]$/, '');
                            if (!(formData[inputName] instanceof Array)) {
                                formData[inputName] = [];
                            }
                            formData[inputName].push(value)
                        } else {
                            formData[inputName] = value;
                        }
                    }

                    if (!!input.attr(_data.validation) || !!input.attr(_data.regex)) {
                        if (!validateInput(input[0], value)) {
                            isValid = false;
                        }
                    }
                }
            );

            prepareFormData();

            return isValid;

        }
965447
function onError(error) {
  	for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  		args[_key - 1] = arguments[_key];
  	}

  	if (config.current) {
  		if (config.current.ignoreGlobalErrors) {
  			return true;
  		}
  		pushFailure.apply(undefined, [error.message, error.fileName + ":" + error.lineNumber].concat(args));
  	} else {
  		test("global failure", extend(function () {
  			pushFailure.apply(undefined, [error.message, error.fileName + ":" + error.lineNumber].concat(args));
  		}, { validTest: true }));
  	}

  	return false;
  }
708054
function _isValid(position, activeMaskset, c, strict) {
                    var testPos = determineTestPosition(position), loopend = c ? 1 : 0, chrs = '', buffer = activeMaskset["buffer"];
                    for (var i = activeMaskset['tests'][testPos].cardinality; i > loopend; i--) {
                        chrs += getBufferElement(buffer, testPos - (i - 1));
                    }

                    if (c) {
                        chrs += c;
                    }

                    //return is false or a json object => { pos: ??, c: ??} or true
                    return activeMaskset['tests'][testPos].fn != null ?
                        activeMaskset['tests'][testPos].fn.test(chrs, buffer, position, strict, opts)
                        : (c == getBufferElement(activeMaskset['_buffer'], position, true) || c == opts.skipOptionalPartCharacter) ?
                            { "refresh": true, c: getBufferElement(activeMaskset['_buffer'], position, true), pos: position }
                            : false;
                }
1258332
function validateJSONResponse(resp, result_schema) {

   const ajv = new Ajv();
   if (result_schema) {
      try {
         const valid = ajv.validate(result_schema, resp);
         assert(valid);
         return resp;
      }
      catch(e) {
         try {
            // error message
            const valid = ajv.validate(CORE_ERROR_SCHEMA, resp);
            assert(valid);
            return resp;
         }
         catch(e2) {
            console.log("Failed to validate with desired schema");
            console.log(e.stack);
            console.log("Failed to validate with error schema");
            console.log(e2.stack);
            console.log("Desired schema:");
            console.log(result_schema);
            console.log("Parsed message:");
            console.log(resp);
            throw new Error("Invalid core message");
         }
      }
   }
   else {
      return resp;
   }
}
1326587
function ValidationError (instance) {
  NeopreneError.call(this, "Validation failed");
  Error.captureStackTrace(this, arguments.callee);
  this.name = 'ValidationError';
  this.errors = instance.errors = {};
}
94851
function logJsHintWarning (errors)
{
    totalIssues += errors.length;

    var sourceFile = pathHelper.makeRelative(this.resourcePath);
    gulpUtil.log(gulpUtil.colors.yellow("jshint warning") + " in " + sourceFile);

    for (var i = 0, l = errors.length; i < l; i++)
    {
        var error = errors[i];

        gulpUtil.log(
            "    in " +
            gulpUtil.colors.blue("line " + error.line + " @ char " + error.character) +
            ": " +
            error.reason +
            " (" + error.code + ")"
        );

        if (typeof error.evidence === "string")
        {
            gulpUtil.log(
                "        " +
                gulpUtil.colors.gray(error.evidence.replace(/^\s*|\s*$/, ""))
            );
        }

        gulpUtil.log("");
    }
}
338177
function validated(invalid){
            if (invalid) { return callback(invalid) }
            if(options.coerce){crudUtils.coerceData(options,coerced())}
            else{coerced(null,options.data)}
        }
399026
function isValid(name, value) {
    var tests = {
        indent: function (value) {
            return (/^(\s*|\d*)$/).test(value);
        },
        openbrace: function (value) {
            return (['end-of-line', 'separate-line']).indexOf(value) !== -1;
        },
        autosemicolon: function (value) {
            return typeof value === 'boolean';
        }
    };

    return Boolean(tests[name] && tests[name](value));
}
912727
function validateCallbacks(options) {
            if (options.successCallback && typeof options.successCallback !== 'function') {
                throw new Error(TAG + 'Success callback must be a function.');
            } else {
                options.successCallback = options.successCallback || enplug.noop;
            }

            if (options.errorCallback && typeof options.errorCallback !== 'function') {
                throw new Error(TAG + 'Error callback must be a function.');
            } else {
                options.errorCallback = options.errorCallback || enplug.noop;
            }
        }