-
-
Notifications
You must be signed in to change notification settings - Fork 629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Add Unique validator #1539
Comments
could be subclass of List or another solution is to use unique=True keyword argument to List field class
|
Not entirely opposed to adding this, but it's a bit tricky to handle both hashable and non-hashable types. Also, it's pretty easy to define this in userland: def validate_uniqueness(value: Sequence):
if len(set(value)) < len(value):
raise ValidationError("Values must be unique.")
class MySchema(Schema):
my_field = fields.List(fields.Str(), validate=validate_uniqueness) I'd recommend doing that for now. |
Closing for now, as we don't have plans to add this to core in the near future and the use case can easily be met in userland (see my comment above) |
Check PR #1793 proposal with support for hashable and non-hashable types, as well as the option of adding nested attributes. |
Validates that all values present in a list input is unique, ie. didn't occur more than once.
The text was updated successfully, but these errors were encountered: