Simplify ListItemsUnique check
This commit is contained in:
parent
92080abe0a
commit
4cb2447edb
@ -64,8 +64,7 @@ def ListItemRequired(message="Please provide at least one.", empty_values=("", N
|
|||||||
|
|
||||||
def ListItemsUnique(message="Items must be unique"):
|
def ListItemsUnique(message="Items must be unique"):
|
||||||
def _list_items_unique(form, field):
|
def _list_items_unique(form, field):
|
||||||
sorted_values = sorted(v for v in field.data)
|
if len(field.data) > len(set(field.data)):
|
||||||
if sorted_values != sorted(set(sorted_values)):
|
|
||||||
raise ValidationError(message)
|
raise ValidationError(message)
|
||||||
|
|
||||||
return _list_items_unique
|
return _list_items_unique
|
||||||
|
Loading…
x
Reference in New Issue
Block a user