validate exclusive use of only or except but not both at the same time
175294
def validate_exclusive_use_of_hash_constraints!(conf, attribute)
      return unless is_hash?(conf)
      if conf.key?(:only) && conf.key?(:except)
        raise CookiesConfigError.new("#{attribute} cookie config is invalid, simultaneous use of conditional arguments `only` and `except` is not permitted.")
      end
    end
1304754
def NOT(fn):
    
    @chainable
    def validator(v):
        try:
            fn(v)
        except ValueError:
            return v
        raise ValueError('invalid')
    return validator
140080
function booleanNonStrict(validatedObject, errorText) {
  if (!_.isBoolean(validatedObject)) {
    if (
      !_.isString(validatedObject) ||
      (validatedObject.toLowerCase() !== 'false' && validatedObject.toLowerCase() !== 'true')
    ) {
      throw new ValidationError(errorText || 'Validated object is not Boolean');
    }
  }
  return validatedObject;
}
899137
def except_handle(tokens):
    """"""
    if len(tokens) == 1:
        errs, asname = tokens[0], None
    elif len(tokens) == 2:
        errs, asname = tokens
    else:
        raise CoconutInternalException("invalid except tokens", tokens)
    out = "except "
    if "list" in tokens:
        out += "(" + errs + ")"
    else:
        out += errs
    if asname is not None:
        out += " as " + asname
    return out
747332
protected function validateCondition($condition)
    {
        $condition = trim(strtolower($condition));

        if ('and' !== $condition && 'or' !== $condition) {
            throw new \Exception("Condition can only be one of: 'and', 'or'.");
        }

        return $condition;
    }
90477
def assertSameType(a, b):
    
    if not isinstance(b, type(a)):
        raise NotImplementedError("This operation is only supported for " \
            "elements of the same type. Instead found {} and {}".
                format(type(a), type(b)))
29534
def containsbb_exclusive(self, x):
        
        left, bottom, right, top = self.aarect().lbrt()
        leftx, bottomx, rightx, topx = x.aarect().lbrt()
        return (left <= leftx) and (bottom <= bottomx) and (right >= rightx) and (top >= topx) and\
               (not ((left == leftx) and (bottom == bottomx) and (right == rightx) and (top == topx)))
1312751
def validate_LESSTHANEQ(value, restriction):
    
    #Sometimes restriction values can accidentally be put in the template <item>100</items>,
    #Making them a list, not a number. Rather than blowing up, just get value 1 from the list.
    if type(restriction) is list:
        restriction = restriction[0]

    value = _get_val(value)
    if type(value) is list:
        for subval in value:
            if type(subval) is tuple:
                subval = subval[1]
            validate_LESSTHANEQ(subval, restriction)
    else:
        try:
            if value > restriction:
                raise ValidationError("LESSTHANEQ: %s" % (restriction))
        except TypeError:
            # Incompatible types for comparison.
            raise ValidationError("LESSTHANEQ: Incompatible types %s"%(restriction))
1322003
def Any(*validators):
    
    @wraps(Any)
    def built(value):
        error = None
        for validator in validators:
            try:
                return validator(value)
            except Error as e:
                error = e
        raise error
    return built
1319596
def _validate_noneof(self, definitions, field, value):
        
        valids, _errors = \
            self.__validate_logical('noneof', definitions, field, value)
        if valids > 0:
            self._error(field, errors.NONEOF, _errors,
                        valids, len(definitions))
1175157
function notStrictEqual(actual, expected, message) {
    if (actual !== expected) {
      this.pass(message);
    }
    else {
      this.fail({
        actual: actual,
        expected: expected,
        message: message,
        operator: "!=="
      })
    }
  }
419450
protected function skipCondition()
	{
		// Reach the opening parenthesis
		$this->skipToString('(');

		// Iterate through tokens until we have a match for every left parenthesis
		$parens = 0;
		while (++$this->i < $this->cnt)
		{
			if ($this->tokens[$this->i] === ')')
			{
				if ($parens)
				{
					--$parens;
				}
				else
				{
					break;
				}
			}
			elseif ($this->tokens[$this->i] === '(')
			{
				++$parens;
			}
		}
	}
683695
function validateOptions(operation, type, useCoerce) {
  var options = { useCoerce: useCoerce };

  // capitalize type
  var suffix = type[0].toUpperCase() + type.slice(1);

  // Get remove option (ex: options.removeHeader)
  var removeAdditional = lookup(operation, 'options', 'remove' + suffix);

  if (typeof removeAdditional === 'undefined') {
    removeAdditional = true;
  }
  options.removeAdditional = !!removeAdditional;

  return options;
}
199497
def any(*validators):
    """"""
    def validate_any(fields):
        errors = {}
        for validator in validators:
            validation_errors = validator(fields)
            if not validation_errors:
                return
            errors.update(validation_errors)
        return errors

    validate_any.__doc__ = " or ".join(validator.__doc__ for validator in validators)
    return validate_any
563574
function checkConditional(node) {
            const nonSpacedConsequesntNode = getFirstNonSpacedToken(node.test, node.consequent, "?");
            const nonSpacedAlternateNode = getFirstNonSpacedToken(node.consequent, node.alternate, ":");

            if (nonSpacedConsequesntNode) {
                report(node, nonSpacedConsequesntNode);
            } else if (nonSpacedAlternateNode) {
                report(node, nonSpacedAlternateNode);
            }
        }
535708
def validate_ok_for_replace(replacement):
    """"""
    validate_is_mapping("replacement", replacement)
    # Replacement can be {}
    if replacement and not isinstance(replacement, RawBSONDocument):
        first = next(iter(replacement))
        if first.startswith('$'):
            raise ValueError('replacement can not include $ operators')
352425
def validate_ok_for_update(update):
    """"""
    validate_is_mapping("update", update)
    # Update can not be {}
    if not update:
        raise ValueError('update only works with $ operators')
    first = next(iter(update))
    if not first.startswith('$'):
        raise ValueError('update only works with $ operators')