refactor
This commit is contained in:
parent
a269cbcc93
commit
e1fef11465
|
@ -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'
|
||||
|
|
Loading…
Reference in New Issue