Skip to content

Conversation

gaetano-guerriero
Copy link
Contributor

Description

This patch adds support for allow_empty option to DictField and HStoreField.

Enforcing that the field value is not empty is a common use case in my opinion.
The same parameter was already supported by the other composite field ListField.

Param defaults to False so current behaviour is not changed.

Copy link
Contributor

@rpkilby rpkilby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from the requests, these changes seem sensible to me. That said, I'd like others to review.

output = field.run_validation(None)
assert output is None

def test_allow_empty(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change the name to test_allow_empty_disallowed (or similar), as test_allow_empty implies allow_empty=True.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, renamed

"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-12 16:13+0100\n"
"POT-Creation-Date: 2019-04-11 23:21+0200\n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translations are managed with transifex and are updated via the release process. These changes should be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, changes in this file have been dropped

@gaetano-guerriero
Copy link
Contributor Author

Thank you for your review, I've applied the changes requested and rebased onto master.

@lovelydinosaur
Copy link
Contributor

Looks spot on to me.
Great work!

@lovelydinosaur lovelydinosaur merged commit a7c577c into encode:master May 9, 2019
terencehonles pushed a commit to terencehonles/django-rest-framework that referenced this pull request Oct 8, 2020
* dict field: support allow_empty option

* document ListField allow_empty option

* document HStoreField allow_empty parameter
pchiquet pushed a commit to pchiquet/django-rest-framework that referenced this pull request Nov 17, 2020
* dict field: support allow_empty option

* document ListField allow_empty option

* document HStoreField allow_empty parameter
sigvef pushed a commit to sigvef/django-rest-framework that referenced this pull request Dec 3, 2022
* dict field: support allow_empty option

* document ListField allow_empty option

* document HStoreField allow_empty parameter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants