public PipeParameterValidator validateAttributeValueRange(
      final String key, final boolean canBeOptional, final String... optionalValues)
      throws PipeAttributeNotProvidedException {
    if (!parameters.hasAttribute(key)) {
      if (!canBeOptional) {
        throw new PipeParameterNotValidException(String.format("Parameter %s should be set.", key));
      }
      return this;
    }

    final String actualValue = parameters.getStringByKeys(key);
    for (String optionalValue : optionalValues) {
      if (actualValue.equals(optionalValue)) {
        return this;
      }
    }

    throw new PipeParameterNotValidException(
        String.format(
            "Invalid value %s of %s. The value should be one of %s",
            actualValue, key, Arrays.toString(optionalValues)));
  }
Validates whether the attributes entered by the user contain an attribute whose key is
attributeKey.

@param key key of the attribute
@throws PipeAttributeNotProvidedException if the attribute is not provided
iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/customizer/parameter/PipeParameterValidator.java