This commit is contained in:
Emmanuel Garette 2020-10-05 21:16:41 +02:00
parent a269cbcc93
commit e1fef11465
1 changed files with 7 additions and 6 deletions

View File

@ -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'