protected function validate($key, $value) {
    if (!isset($this->defaults[$key])) {
      $factory_method = 'get_' . $key;
      if (!method_exists($this, $factory_method)) {
        // Keys are only 'known' if there is a get_ method.
        throw new MiniContainerException(sprintf('Unknown key "%s"', $key));
      }
    }
    $validate_method = 'validate_' . $key;
    if (!method_exists($this, $validate_method)) {
      // Keys can only be initialized if there is a validate method.
      throw new MiniContainerException(sprintf('Key "%s" is known, but has no validate method.', $key));
    }
    $this->$validate_method($value);
  }