-
Notifications
You must be signed in to change notification settings - Fork 215
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
plan to develop a feature about 'default value for optional key'? #12
Comments
Hm... interesting. Something like: Schema({'foo': Or(str, Default('bar'))}) or maybe: Schema({'foo': Or(str, default='bar')}) What do you think? |
Or maybe something like: >>> from schema import Optional
>>> Schema({'name': str,
... Optional('occupation', default='dentist'): str}).validate({'name': 'Sam'})
{'name': 'Sam', 'occupation': 'dentist'} What do you think? |
I have implemented the second idea based on your program, but I like the first more. :) |
I see a problem here with your proposals: you are defining the default value in the key part. The problem is visible when keys are something like Trying to find an API… tell me what you prefer! (and they are not to be exclusive)
I am for option 3, as it makes the Also, in case
Tell me if it makes sense, or if you have any other idea. |
I tried to implement the third API, and I added a I let you go and see #19 if you want to give it a try and comment there ;-) |
As the initial request has been implemented and the discussion has shifted to #19, I believe this can be closed. |
No description provided.
The text was updated successfully, but these errors were encountered: