diff --git a/tiramisu/option/choiceoption.py b/tiramisu/option/choiceoption.py index babf658..29e2f42 100644 --- a/tiramisu/option/choiceoption.py +++ b/tiramisu/option/choiceoption.py @@ -76,17 +76,18 @@ class ChoiceOption(Option): if isinstance(self._choice_values, Calculation): return values = self._choice_values - if values is not undefined and value not in values: - if len(values) == 1: - raise ValueError(_('only "{0}" is allowed' - '').format(values[0])) - raise ValueError(_('only {0} are allowed' - '').format(display_list(values, add_quote=True))) + self.validate_values(value, values) async def validate_with_option(self, value: Any, option_bag: OptionBag) -> None: values = await self.impl_get_values(option_bag) + self.validate_values(value, values) + + def validate_values(self, + value, + values, + ) -> None: if values is not undefined and value not in values: if len(values) == 1: raise ValueError(_('only "{0}" is allowed'