-
Notifications
You must be signed in to change notification settings - Fork 218
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
Fix #379: Regression with Any and required #380
Fix #379: Regression with Any and required #380
Conversation
Aaah, nice find. Thank you for the PR. Just one minor change and I'm happy to merge. |
I just amend my commit with your remark. Thanks However, I just found out that some case do not work :-( like "dict in dict", the empty dict is considered valid but should not
If it's ok, I'll try to come back to you with another commit on this branch to fix that. |
Here is the 2nd part of the patch to allow "recursive schema" |
In 0.9.3, the `Schema`s associated to the `Any` validators where setup with the `required` argument given to `Any` https://github.com/alecthomas/voluptuous/blob/0.9.3/voluptuous/validators.py#L218 This allow us to write something like: ``` Schema(Any({'a': int}, {'b': str}, required=True)) ``` In recent version, the `required` keyword is ignored. This patch pass the required argument to the `Schema`s associated with the `SubValidator`.
] | ||
self._compiled = [] | ||
for v in self.validators: | ||
schema.required = self.required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still a leftover? Should this be v.required = self.required
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it is correct. Test fail otherwise
Also note that the line must be inside the loop. I'm not totally clear on what happen... but tests are passing ...
Thanks! |
In 0.9.3, the
Schema
s associated to theAny
validators where setup with therequired
argument given toAny
https://github.com/alecthomas/voluptuous/blob/0.9.3/voluptuous/validators.py#L218
This allow us to write something like:
In recent version, the
required
keyword is ignored.This patch pass the required argument to the
Schema
s associated with theSubValidator
.