django-partial-index
django-partial-index copied to clipboard
Improve validation errors in mixin
This has several improvements to how validation errors are raised by the mixin:
- Use the Django built-in validation error generation to produce better errors:
- The name of the field that triggered the validation error is used as the error dictionary key if it's a single field. This helps to highlight the field in a frontend.
- For JSON-based APIs the
code
field is very useful to determine what is wrong with that particular field, and we rely on this in our project at work
- When there are failing "standard" uniqueness checks, do not bail out early but merge partial unique validation errors into the standard errors.
- When there are multiple partially unique indexes that trigger a uniqueness error, all errors are returned instead of just the first.
This builds on #15 so please take a look at that one first.
Why no feedback on this PR?
I'm relying on this code in production, and it's essential for us, in case you're doubting the use of this.