public static function getOptionsValidator(array $options) {
    return function ($value) use ($options) {
      if (!in_array($value, $options)) {
        $options_formatted = implode(', ', $options);
        $error_message = sprintf('The value should be one of the following: %s.', $options_formatted);
        throw new \UnexpectedValueException($error_message);
      }
      return $value;
    };
  }