Checks if a key is valid and raises a ValueError if its not.

        When in need of checking a key for validity, always use this
        method if possible.

        :param key: The key to be checked
166644
def _check_valid_key(self, key):
        
        if not isinstance(key, key_type):
            raise ValueError('%r is not a valid key type' % key)
        if not VALID_KEY_RE.match(key):
            raise ValueError('%r contains illegal characters' % key)
953021
def validate_key(self, key):
        
        if len(key) > 250:
            raise ValueError(
                "Cache key is longer than the maxmimum 250 characters: {}"
                .format(key),
            )
        return super(MySQLCache, self).validate_key(key)
923049
def _validate_key(self, key):
        
        if key == () and len(self.kdims) == 0: return ()
        key = util.wrap_tuple(key)
        assert len(key) == len(self.kdims)
        for ind, val in enumerate(key):
            kdim = self.kdims[ind]
            low, high = util.max_range([kdim.range, kdim.soft_range])
            if util.is_number(low) and util.isfinite(low):
                if val < low:
                    raise KeyError("Key value %s below lower bound %s"
                                   % (val, low))
            if util.is_number(high) and util.isfinite(high):
                if val > high:
                    raise KeyError("Key value %s above upper bound %s"
                                   % (val, high))
1223435
def _check_for_invalid_keys(fname, kwargs, compat_args):
    
    # set(dict) --> set of the dictionary's keys
    diff = set(kwargs) - set(compat_args)

    if diff:
        bad_arg = list(diff)[0]
        raise TypeError(("{fname}() got an unexpected "
                         "keyword argument '{arg}'".
                         format(fname=fname, arg=bad_arg)))
917433
def _validate(self, key, val, arg_types):
        
        if key in arg_types:
            arg_type = arg_types[key]
        else:
            if ANY_ARG not in arg_types:
                raise CloudantArgumentError(116, key)
            arg_type = arg_types[ANY_ARG]

        if arg_type == ANY_TYPE:
            return
        if (not isinstance(val, arg_type) or
                (isinstance(val, bool) and int in arg_type)):
            raise CloudantArgumentError(117, key, arg_type)
        if isinstance(val, int) and val < 0 and not isinstance(val, bool):
            raise CloudantArgumentError(118, key, val)
        if key == 'feed':
            valid_vals = ('continuous', 'normal', 'longpoll')
            if self._source == 'CouchDB':
                valid_vals = ('continuous', 'longpoll')
            if val not in valid_vals:
                raise CloudantArgumentError(119, val, valid_vals)
        if key == 'style' and val not in ('main_only', 'all_docs'):
            raise CloudantArgumentError(120, val)
717686
def check(self):
        
        try:
            value = self.raw_value
        except (AttributeError, KeyError) as err:
            self._reraise_if_required(err)
        else:
            if self.checker:
                self.checker(self.full_name, value)
            try:
                self.validate(value)
                self.run_validators(value)
            except ValidationError as error:
                raise ValueError("Setting {} has an invalid value: {}".format(self.full_name, error))
208137
def check_key(self, key):
        """"""
        return _check_key(key, allow_unicode_keys=self.allow_unicode_keys,
                          key_prefix=self.key_prefix)
1246592
def _validate_key(self, key):
        """"""
        return not any([key.startswith(i) for i in self.EXCEPTIONS])
440099
def assert_valid(self, instance, value=None):
        
        if value is None:
            value = instance._get(self.name)
        if (
                value is not None and
                not self.equal(value, self.validate(instance, value))
        ):
            message = 'Invalid value for property: {}: {}'.format(
                self.name, value
            )
            raise ValidationError(message, 'invalid', self.name, instance)
        return True
225492
def has_key(self, key):
        
        if key in self._dict:
            try: 
                self[key]
                return True
            except ValueError:
                return False
            except KeyError:
                return False
        return False
1227973
def validate(self, value):
        
        if not isinstance(value, dict):
            self.raise_error('Only Python dict may be used in the DictField vs provided {0}'
                             .format(type(value).__name__))
        super(DictField, self).validate(value)
1214266
def validate(key):
    
    if not isinstance(key, (str, bytes)):
        raise KeyError('Key must be of type str or bytes, found type {}'.format(type(key)))
25322
def is_locked(self, key):
        
        key = str(key)
        if key in self.__variable_locks:
            return self.__variable_locks[key].locked()
        return False
361147
def validate_key(key: str):
        
        if "//" in key:
            raise DoubleSlashKeyError(key)
        elif normpath(key) != key:
            raise NonNormalisedKeyError(key)
1356194
def validate_public_key(value):
    
    is_valid = False
    exc = None

    for load in (load_pem_public_key, load_ssh_public_key):
        if not is_valid:
            try:
                load(value.encode('utf-8'), default_backend())
                is_valid = True
            except Exception as e:
                exc = e

    if not is_valid:
        raise ValidationError('Public key is invalid: %s' % exc)
425363
def validate_config(key: str, config: dict) -> None:
    

    try:
        jsonschema.validate(config, CONFIG_JSON_SCHEMA[key])
    except jsonschema.ValidationError as x_validation:
        raise JSONValidation('JSON validation error on {} configuration: {}'.format(key, x_validation.message))
    except jsonschema.SchemaError as x_schema:
        raise JSONValidation('JSON schema error on {} specification: {}'.format(key, x_schema.message))
1198137
def validate_keys(*valid_keys)
      valid_keys.flatten!
      @hash.each_key do |k|
        unless valid_keys.include?(k)
          raise ArgumentError.new("Unknown key: #{k.inspect}. Valid keys are: #{valid_keys.map(&:inspect).join(', ')}")
        end
      end
    end