Skip to content

Bulk creation validation #4828

Closed
Closed

Description

@jared-mackey

How do I create validators for bulk APIs? For example a bulk user endpoint that would validate that the uploaded data didn't contain any duplicate emails. The issue is that the current list serializers validate each object individually but not as a group so it is possible for it to get a validation error raised when I call serializer.save() after half of the objects were saved and I hit the duplicate. This can be a big problem where the users expect these to happen in a transaction like scenario where it either works for all or sends back an error and doesn't make any changes. Instead, it is making some changes and then sending back a 500 with the Django validation error.

I propose being able to write functions like validate_emails on a bulk serializer like class and get a list of all the emails that were uploaded in the bulk. That way I could easily write something like if len(emails) != len(set(emails)): raise ValidationError('Duplicate emails).

Activity

  1. xordoquy commented on Jan 19, 2017

    @xordoquy
    Contributor

    The discussion group is the best place to take this discussion and other usage questions. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions