-
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
Ability to have recursive schema #128
Comments
It's not clear to me how that could be expressed any other way than something similar to what you have? |
It's not clear to me either, I didn't find any other elegant solution. But it'd be nice if someone did. :) |
So I tried the following (might be something I'm missing since it doesn't work, ha). But that seems like it could be a way to do this... |
I think the solution @jd came up with is fine. |
@alecthomas Solution is good enough but It would be fine to have it in documentation somewhere for others. I can prepare PR if you are busy :) |
That would be great, thanks! |
Added recursive schema into README #128
This allows to refer to the current schema using voluptuous.Self and have nested definitions. Fixes alecthomas#128
* Allow to use nested schema This allows to refer to the current schema using voluptuous.Self and have nested definitions. Fixes #128 * Allow any validator to be compiled This allows any validator to be compiled by implementing the __voluptuous_compile__ method. This avoids having voluptuous.Any and voluptuous.All defining new Schema for sub-validators: they can be compiled recursively using the same parent schema. This solves the recursive Self case. Fixes #18
Today there's no easy syntax to have a recursive schema. The best way to do it is to have a wrapper like that:
The text was updated successfully, but these errors were encountered: