def _validate(config_dict, config_fields):
	"""Validate a parsed config dictionary

	Validates the contents of config_dict against the fields
	defined in this CheckedConfig. Makes sure that all required
	fields are present and have appropriate values.

	Args:
	  config_dict: a dictionary containing config fields and
		values to validate.

	Returns:
	  A dictionary of validated fields and values.
	"""
	valid_dict = {}
	for field in config_fields:
		try:
			value = config_dict[field.name]
		except KeyError:
			if field.default is not None:
				value = field.default
			else:
				raise ValueError("Missing config field: '{0}'".format(field.name))

		valid_dict[field.name] = field.validate(value)
	return valid_dict