Raises an error if the setting receives an invalid value
 @param config [String] the value to be assigned
 @param allowed_values [Array] an array of allowed values for the variable
 @return [nil]
357931
def validate_value(config, allowed_values)
      value = instance_variable_get("@#{config}")

      return unless invalid_value?(value, allowed_values)

      message = "Configuration value `#{value}` is not allowed for `#{config}`."
      raise ConfigurationError, message
    end
663389
def validate_config(self, config):
        

        try:
            hosts = config['hosts']
        except KeyError:
            raise InvalidConfigurationError('hosts', "",
                                            reason=('hosts configuration '
                                                    'section is required'))

        for key in config.keys():
            if key not in default_allowed_keys:
                raise InvalidConfigurationError(key, config[key])

        bucket = False
        # optional configuration
        try:
            for key in config['aws'].keys():
                if key == 'bucket' and config['aws'][key] is not None:
                    bucket = True
                if key not in aws_allowed_keys:
                    raise InvalidConfigurationError(key, config['aws'][key])
        except KeyError:
            pass

        # optional configuration
        try:
            for key in config['logging'].keys():
                if key not in logging_allowed_keys:
                    raise InvalidConfigurationError(key, config['logging'][key])
        except KeyError:
            pass

        # optional configuration
        try:
            for key in config['repository'].keys():
                if key not in repository_allowed_keys:
                    raise InvalidConfigurationError(key, config['repository'][key])
        except KeyError:
            pass

        # required configuration
        if type(config['hosts']) is not list:
            raise InvalidConfigurationError('hosts', config['hosts'],
                                            reason="hosts must be a list")
        filename = False
        for host in config['hosts']:
            for key in host.keys():
                if key == 'filename' and host['filename'] is not None:
                    filename = True
                if key == 'jump_host' and host['jump_host'] is not None:
                    for jump_key in host['jump_host'].keys():
                        if jump_key not in jump_host_allowed_keys:
                            raise InvalidConfigurationError(key, host['jump_host'])
                if key not in host_allowed_keys:
                    raise InvalidConfigurationError(key, host[key])

        if bucket and filename:
            raise InvalidConfigurationError('bucket', config['aws']['bucket'],
                                            reason=('bucket configuration is'
                                                    'incompatible with filename'
                                                    'configuration in hosts'))
1304298
def config_option(name, default_value, options = {})
      compiler      = options.fetch(:compiler_option, nil)
      valid_values  = options.fetch(:valid_values, [true, false])

      config_options[name] = {
        default: default_value,
        compiler: compiler
      }

      define_singleton_method(name) { config.fetch(name, default_value) }
      define_singleton_method("#{name}=") do |value|
        unless valid_values.any? { |valid_value| valid_value === value }
          raise ArgumentError, "Not a valid value for option #{self}.#{name}, provided #{value.inspect}. "\
                               "Must be #{valid_values.inspect} === #{value.inspect}"
        end

        config[name] = value
      end
    end
1200283
function _validateConfig(config) {
    for (var i = 0; i < REQUIRED_CONFIG_VARIABLES.length; i++) {
        var key = REQUIRED_CONFIG_VARIABLES[i];
        var value = config.DubBotBase[key];
        if (!value || value === "UNSET") {
            throw new Error("No value has been set in config for key: DubBotBase." + key);
        }
    }
}
397545
def config(self, value: dict) -> None:
        

        self._config = value or {}
        validate_config('verifier', self._config)
797566
function validateConfig (config) {
  var type = typeOf(config);

  if (type.hasValue && !type.isPOJO) {
    throw ono('Invalid arguments. Expected a configuration object.');
  }
}
826112
def is_in(allowed_values  # type: Set
          ):
    
    def is_in_allowed_values(x):
        if x in allowed_values:
            return True
        else:
            # raise Failure('is_in: x in ' + str(allowed_values) + ' does not hold for x=' + str(x))
            raise NotInAllowedValues(wrong_value=x, allowed_values=allowed_values)

    is_in_allowed_values.__name__ = 'is_in_{}'.format(allowed_values)
    return is_in_allowed_values
754592
def set_config_value(self, name, value):
        
        if value is True:
            value = "True"
        elif value is False:
            if name in self.config_dict:
                del self.config_dict[name]
                self.config_changed = True
            return
        if name not in self.config_dict or self.config_dict[name] != value:
            self.config_changed = True
            self.config_dict[name] = value
863561
def _validate_config(config):
    
    try:
        referenced_sublists = set()
        for key, listdef in list(config.items()):
            # Check if section is a list
            if not isinstance(listdef, dict):
                raise ValueError('Value at key {!r} is not a dict'
                                 .format(key))
            # Check if it has correct type
            if _CONF.FIELD.TYPE not in listdef:
                raise ValueError('Config at key {!r} has no {!r}'
                                 .format(key, _CONF.FIELD.TYPE))
            # Nested or Cartesian
            if listdef[_CONF.FIELD.TYPE] in (_CONF.TYPE.NESTED, _CONF.TYPE.CARTESIAN):
                sublists = listdef.get(_CONF.FIELD.LISTS)
                if sublists is None:
                    raise ValueError('Config at key {!r} has no {!r}'
                                     .format(key, _CONF.FIELD.LISTS))
                if (not isinstance(sublists, list) or not sublists or
                        not all(_is_str(x) for x in sublists)):
                    raise ValueError('Config at key {!r} has invalid {!r}'
                                     .format(key, _CONF.FIELD.LISTS))
                referenced_sublists.update(sublists)
            # Const
            elif listdef[_CONF.FIELD.TYPE] == _CONF.TYPE.CONST:
                try:
                    value = listdef[_CONF.FIELD.VALUE]
                except KeyError:
                    raise ValueError('Config at key {!r} has no {!r}'
                                     .format(key, _CONF.FIELD.VALUE))
                if not _is_str(value):
                    raise ValueError('Config at key {!r} has invalid {!r}'
                                     .format(key, _CONF.FIELD.VALUE))
            # Words
            elif listdef[_CONF.FIELD.TYPE] == _CONF.TYPE.WORDS:
                try:
                    words = listdef[_CONF.FIELD.WORDS]
                except KeyError:
                    raise ValueError('Config at key {!r} has no {!r}'
                                     .format(key, _CONF.FIELD.WORDS))
                if not isinstance(words, list) or not words:
                    raise ValueError('Config at key {!r} has invalid {!r}'
                                     .format(key, _CONF.FIELD.WORDS))
                # Validate word length
                try:
                    max_length = int(listdef[_CONF.FIELD.MAX_LENGTH])
                except KeyError:
                    max_length = None
                if max_length is not None:
                    for word in words:
                        if len(word) > max_length:
                            raise ValueError('Config at key {!r} has invalid word {!r} '
                                             '(longer than {} characters)'
                                             .format(key, word, max_length))
            # Phrases (sequences of one or more words)
            elif listdef[_CONF.FIELD.TYPE] == _CONF.TYPE.PHRASES:
                try:
                    phrases = listdef[_CONF.FIELD.PHRASES]
                except KeyError:
                    raise ValueError('Config at key {!r} has no {!r}'
                                     .format(key, _CONF.FIELD.PHRASES))
                if not isinstance(phrases, list) or not phrases:
                    raise ValueError('Config at key {!r} has invalid {!r}'
                                     .format(key, _CONF.FIELD.PHRASES))
                # Validate multi-word and max length
                try:
                    number_of_words = int(listdef[_CONF.FIELD.NUMBER_OF_WORDS])
                except KeyError:
                    number_of_words = None
                try:
                    max_length = int(listdef[_CONF.FIELD.MAX_LENGTH])
                except KeyError:
                    max_length = None
                for phrase in phrases:
                    phrase = _split_phrase(phrase)  # str -> sequence, if necessary
                    if not isinstance(phrase, (tuple, list)) or not all(isinstance(x, _str_types) for x in phrase):
                        raise ValueError('Config at key {!r} has invalid {!r}: '
                                         'must be all string/tuple/list'
                                         .format(key, _CONF.FIELD.PHRASES))
                    if number_of_words is not None and len(phrase) != number_of_words:
                        raise ValueError('Config at key {!r} has invalid phrase {!r} '
                                         '({} word(s) but {}={})'
                                         .format(key, ' '.join(phrase),
                                                 len(phrase), _CONF.FIELD.NUMBER_OF_WORDS, number_of_words))
                    if max_length is not None and sum(len(word) for word in phrase) > max_length:
                        raise ValueError('Config at key {!r} has invalid phrase {!r} '
                                         '(longer than {} characters)'
                                         .format(key, ' '.join(phrase), max_length))
            else:
                raise ValueError('Config at key {!r} has invalid {!r}'
                                 .format(key, _CONF.FIELD.TYPE))
        # Check that all sublists are defined
        diff = referenced_sublists.difference(config.keys())
        if diff:
            raise ValueError('Lists are referenced but not defined: {}'
                             .format(', '.join(sorted(diff)[:10])))
    except (KeyError, ValueError) as ex:
        raise ConfigurationError(str(ex))
97070
def stringify(allowed_keys: nil, allowed_vals: nil)
      keys = allowed_keys || self.class.allowed[:keys]

      map do |v|
        v = v.to_s unless keys.include?(v.class)
        !v.respond_to?(:stringify) ? v : v.stringify({
          :allowed_keys => allowed_keys,
          :allowed_vals => allowed_vals
        })
      end
    end
693085
def remove_highest(var)
      configs.each do |c|
        if c.has_var?(var)
          return c.remove_var(var)
        end
      end

      # return nil if we haven't returned a value yet
      nil
    end
301113
def valid?(options)
      valid_options = Loaf::Configuration::VALID_ATTRIBUTES
      options.each_key do |key|
        unless valid_options.include?(key)
          fail Loaf::InvalidOptions.new(key, valid_options)
        end
      end
      true
    end
53957
def set(self, val, default=False, imported=False):
        
        if hasattr(self.validator, '__call__'):
            try:
                val = self.validator(val)
            except Exception as exc:
                raise type(exc)(
                    'Could not validate value for "%s" setting: %s' %
                    (self.name, exc)
                ) from None
        self.value = val
        self.imported = imported
        if default:
            self.default = val
        self.modified = True
289364
def validate_available_choice(enum, to_value):
    
    if to_value is None:
        return

    if type(to_value) is not int:
        try:
            to_value = int(to_value)
        except ValueError:
            message_str = "'{value}' cannot be converted to int"
            message = _(six.text_type(message_str))
            raise InvalidStatusOperationError(message.format(value=to_value))

    if to_value not in list(dict(enum.choices()).keys()):
        message = _(six.text_type('Select a valid choice. {value} is not one of the available choices.'))
        raise InvalidStatusOperationError(message.format(value=to_value))
592009
def validate_configs(self):
        
        # Check required arguments, validate values
        for conf in self.REQUIRED_CONFIGS:
            if conf not in self._config:
                raise MissingConfigError('Missing required configuration %s' % conf)
34753
def assert_valid_value(value)
      unless valid?(value)
        raise Property::InvalidValueError.new(self,value)
      end
      true
    end
959465
function _validateConfig (options) {
    // validate writable options
    if (client || options.master) {
      // when we are a slave, we can't adjust the config, except for
      // changing the master url or becoming a master itself (port configured)
      for (var prop in options) {
        if (prop !== 'master' && prop !== 'slave') {
          throw new Error('Cannot apply configuration option "'  + prop +'", timer is configured as slave.');
        }
      }
    }
  }