Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Allow options to be outside of min/max in validator #1282

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -9,6 +9,7 @@

import org.eclipse.smarthome.config.core.ConfigDescriptionParameter;
import org.eclipse.smarthome.config.core.ConfigDescriptionParameter.Type;
import org.eclipse.smarthome.config.core.ParameterOption;
import org.eclipse.smarthome.config.core.validation.ConfigValidationMessage;
import org.eclipse.smarthome.config.core.validation.internal.TypeIntrospections.TypeIntrospection;

Expand All @@ -17,6 +18,7 @@
* {@link ConfigDescriptionParameter}.
*
* @author Thomas Höfer - Initial contribution
* @authod Chris Jackson - Allow options to be outside of min/max value
* @param <T>
*/
final class MinMaxValidator implements ConfigDescriptionParameterValidator {
Expand All @@ -34,6 +36,14 @@ public ConfigValidationMessage validate(ConfigDescriptionParameter parameter, Ob
return null;
}

// Allow specified options to be outside of the min/max value
for (ParameterOption option : parameter.getOptions()) {
// Option values are a string, so we can do a simple compare
if (option.getValue().equals(value.toString())) {
return null;
}
}

TypeIntrospection typeIntrospection = TypeIntrospections.get(parameter.getType());

if (parameter.getMinimum() != null) {
Expand Down