Skip to content
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

required=True takes in empty values #103

Open
czue opened this issue Sep 24, 2014 · 6 comments
Open

required=True takes in empty values #103

czue opened this issue Sep 24, 2014 · 6 comments

Comments

@czue
Copy link
Member

czue commented Sep 24, 2014

class MyObject(JsonObject):
    required_thing = StringProperty(required=True)

MyObject.wrap({'required_thing': ''})  # this doesn't fail ... should it?
@dannyroberts
Copy link
Member

Good question. I just documented the intended behavior here: #104.

@dannyroberts
Copy link
Member

@czue
Copy link
Member Author

czue commented Sep 25, 2014

i would argue that accepting an empty string is surprising and confusing, but won't push too hard on it.

@czue
Copy link
Member Author

czue commented Sep 25, 2014

maybe could add blank=True similar to djangos CharField

@dannyroberts
Copy link
Member

Good feedback, and I'll keep that in the back of my mind as I rework.
Generally, this library is used so heavily in our code that all api
behaviors, even strange ones, are relied upon somewhere, so it has to be
done thoughtfully.
On Sep 25, 2014 12:32 PM, "Cory Zue" [email protected] wrote:

i would argue that accepting an empty string is surprising and confusing,
but won't push too hard on it.


Reply to this email directly or view it on GitHub
#103 (comment).

@dannyroberts dannyroberts reopened this Sep 25, 2014
@dannyroberts
Copy link
Member

Leaving this issue open as a reminder to implement blank=True option:

class MyObject(JsonObject):
    not_blank_thing = StringProperty(blank=True)

>>> MyObject.wrap({'not_blank_thing': ''})
...
BadValueError: Property not_blank_thing cannot be blank.

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

No branches or pull requests

2 participants