check uniq value for a slave

This commit is contained in:
2017-03-06 22:35:32 +01:00
parent 58a90a3707
commit 7977efe246
2 changed files with 17 additions and 4 deletions

View File

@ -661,10 +661,16 @@ class Option(OnlyOption):
if err:
return err
else:
if self.impl_is_unique() and value in multi:
return ValueError(_('invalid value "{}", this value is already'
' in "{}"').format(value,
self.impl_get_display_name()))
if multi is not None and self.impl_is_unique() and value in multi:
if not self.impl_is_submulti() and len(multi) - 1 >= force_index:
lst = list(multi)
lst.pop(force_index)
else:
lst = multi
if value in lst:
return ValueError(_('invalid value "{}", this value is already'
' in "{}"').format(value,
self.impl_get_display_name()))
return do_validation(value, force_index, force_submulti_index)
elif not isinstance(value, list):
return ValueError(_('invalid value "{0}" for "{1}" which '