Verifies that the parameter dict given by the user only contains
        known keys. This ensures that the user detects typos faster.
433826
def _check_user_parameters(self, user_parameters):
        
        if not user_parameters:
            return

        # sanity check against typos
        for key in user_parameters:
            if key not in submission_defaults:
                raise ValueError("Unknown parameter {0}".format(key))
621191
def _trim_dictionary_parameters(self, dict_param):
        """"""
        # NOTE(luisg): Here we trim down the dictionary passed as parameters
        # to avoid carrying a lot of unnecessary weight around in the message
        # object, for example if someone passes in Message() % locals() but
        # only some params are used, and additionally we prevent errors for
        # non-deepcopyable objects by unicoding() them.

        # Look for %(param) keys in msgid;
        # Skip %% and deal with the case where % is first character on the line
        keys = re.findall('(?:[^%]|^)?%\((\w*)\)[a-z]', self.msgid)

        # If we don't find any %(param) keys but have a %s
        if not keys and re.findall('(?:[^%]|^)%[a-z]', self.msgid):
            # Apparently the full dictionary is the parameter
            params = self._copy_param(dict_param)
        else:
            params = {}
            # Save our existing parameters as defaults to protect
            # ourselves from losing values if we are called through an
            # (erroneous) chain that builds a valid Message with
            # arguments, and then does something like "msg % kwds"
            # where kwds is an empty dictionary.
            src = {}
            if isinstance(self.params, dict):
                src.update(self.params)
            src.update(dict_param)
            for key in keys:
                params[key] = self._copy_param(src[key])

        return params
1323454
def check_keys_split(self, decoded):
        
        bad_keys = set(decoded.keys()).difference(set(self._split_keys))
        if bad_keys:
            bad_keys = ", ".join(bad_keys)
            raise ValueError("JSON data had unexpected key(s): {bad_keys}"
                             .format(bad_keys=pprint_thing(bad_keys)))
1048522
def _validateAttrs(self, keys):
        """"""
        badAttrs = []
        for k in keys:
            if k not in self.__dict__:
                badAttrs.append("Attribute key '%s' is not a valid attribute"%(k))
        badAttrsMsg = os.linesep.join(badAttrs)
        if not keys: return # is iterable, but didn't contain any keys
        if badAttrsMsg:
            raise ValueError("Encountered invalid attributes.  ALLOWED: %s%s%s"\
                %(list(self.__dict__), os.linesep, badAttrsMsg))
1100596
def is_valid_key(key):
    

    if PY3 and isinstance(key, bytes):
        raise TypeError("needs to be str not bytes")

    for c in key:
        if c < " " or c > "}" or c == "=":
            return False
    else:
        return bool(key)
1341069
def isscan(self, key, *, match=None, count=None):
        
        return _ScanIter(lambda cur: self.sscan(key, cur,
                                                match=match,
                                                count=count))
1086598
function validateParamsPresent(expectedKeys, params) {
  params = params || {};
  var paramKeys = _.keys(params);
  return _.first(_.difference(expectedKeys, _.intersection(paramKeys, expectedKeys)));
}
861617
protected static void validateParamsPresence(Map params, String... keys) {
        for (String name : keys) {
            if (!params.containsKey(name)) {
                throw new IllegalArgumentException("parameter: '" + name + "' is missing");
            }
        }
    }
192132
def verify_key(self, url):
        
        
        response = self._request('verify-key', {
            'blog': url,
            'key': self._key
        })
        
        if response.status is 200:
            # Read response (trimmed of whitespace)
            return response.read().strip() == "valid"
            
        return False
194858
def _check_for_misplaced(xs, subkey, other_keys):
    
    problems = []
    for x in xs:
        check_dict = x.get(subkey, {})
        for to_check in other_keys:
            if to_check in check_dict:
                problems.append((x["description"], to_check, subkey))
    if len(problems) > 0:
        raise ValueError("\n".join(["Incorrectly nested keys found in sample YAML. These should be top level:",
                                    " sample         |   key name      |   nested under ",
                                    "----------------+-----------------+----------------"] +
                                   ["% 15s | % 15s | % 15s" % (a, b, c) for (a, b, c) in problems]))
1324872
def only_extras(self):
        
        known = [key for key in self._dict.keys() if key in self.c_param]
        if not known:
            return True
        else:
            return False
28586
function _hasApproximateKey(object, search) {
        var properties = Object.keys(object),
          prop, flag;
        return 0 < properties.filter(function (elm) {
          prop = object[elm];

          //avoid iteration if we found some key that equal[performance]
          if(flag) return true;

          if (isString(prop)) {
            prop = (sensitive) ? prop : prop.toLowerCase();
            return flag = (hasApproxPattern(prop, search) !== false);
          }

          return false;

        }).length;
      }
307062
def _check_key(key, allow_unicode_keys, key_prefix=b''):
    """"""
    if allow_unicode_keys:
        if isinstance(key, six.text_type):
            key = key.encode('utf8')
    elif isinstance(key, VALID_STRING_TYPES):
        try:
            if isinstance(key, bytes):
                key = key.decode().encode('ascii')
            else:
                key = key.encode('ascii')
        except (UnicodeEncodeError, UnicodeDecodeError):
            raise MemcacheIllegalInputError("Non-ASCII key: '%r'" % key)

    key = key_prefix + key
    parts = key.split()

    if len(key) > 250:
        raise MemcacheIllegalInputError("Key is too long: '%r'" % key)
    # second statement catches leading or trailing whitespace
    elif len(parts) > 1 or parts[0] != key:
        raise MemcacheIllegalInputError("Key contains whitespace: '%r'" % key)
    elif b'\00' in key:
        raise MemcacheIllegalInputError("Key contains null: '%r'" % key)

    return key
1268728
private void verifyKeyExistenceMatchesExpectation(JsonObject jsonDataToValidate) {
        boolean jsonDataContainsKey = jsonDataToValidate.containsKey(validationKey);
        if (expCheckType == JsonCheckType.KEY_DOES_NOT_EXIST) {
            assertFalse("The provided content contains a \"" + validationKey + "\" key but should not. The content to validate was: [" + jsonDataToValidate + "].", jsonDataContainsKey);
        } else {
            assertTrue("The provided content does not contain a \"" + validationKey + "\" key but should. The content to validate was: [" + jsonDataToValidate + "].", jsonDataContainsKey);
        }
    }
1246592
def _validate_key(self, key):
        """"""
        return not any([key.startswith(i) for i in self.EXCEPTIONS])
976287
def assert_keys_are_subset(dict1, dict2):
    
    keys1 = set(dict1.keys())
    keys2 = set(dict2.keys())
    unknown_keys = keys2.difference(keys1)
    assert len(unknown_keys) == 0, 'unknown_keys=%r' % (unknown_keys,)
160972
def verify(self, token, verifying_key_or_keys, num_required=None):
        
        if not isinstance(verifying_key_or_keys, (list, str, unicode)):
            raise ValueError("Invalid verifying key(s): expected list or string")

        if isinstance(verifying_key_or_keys, list):
            return self._verify_multi(token, verifying_key_or_keys, num_required=num_required)

        else:
            return self._verify_single(token, str(verifying_key_or_keys))