-
Notifications
You must be signed in to change notification settings - Fork 86
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
Union of schemas #163
Comments
Wait... just so i get this right. Do you want the schema to do a Deep merge between two different schemas into one single schema inside the lib itself and then do the merged validation on the data part? So in your example, the merged schema would be this?
|
That would be the idea. I could do it upstream in my code and submit only the "merged" schema to PyKwalify, but it seemed like a feature that would sit better in PyKwalify (being reusable by other have a similar use case) than in my package where it would be harder to reuse in other projects. |
@christian-oreilly I and strongly leaning towards not supporting this feature mainly due to the reason that if i make some kind of schema union feature, i would have to take a strong stance on several different cases in how the union works with deep and nested data structures. And i am not willing to go down that route and define a certain method or rule set for how it would work inside the pykwalify core. I have in the past been thinking about the same kind of issue and same as then, i passed on it as it would just lead to more code to maintain and probably so many more config and tweak options down the line that i am just not willing to support in the end and would probably casue more harm or issues then what it is worth for me. Basically what i am saying, is that it is not up to pykwalify to define how a schema union would work out, that Must be solved by the person that uses this tool. You have to provide a fully done schema to pykwalify and i will not change this behaviour. If you are using this code as a lib inside your own application, then it should not be difficult to merge them before you send them into the Core class here. |
Sure, no problem. I'll implement it on my side, Thanks for the fast feedback. |
Proposed Functionality
I propose to modify the signature of Core.validate(...) to have something like
When
allow_union == True
would succeed with
schema1
:schema2
:and
source
:Use Case
I am coding a configuration manager package to use in some of my other projects. The idea is to have a class that manage configuration files specificied at various levels (application, project, user, ...). These different configuration files get merged into one configuration. Configuration files can be validated against schemas (using PyKwalify). I now need to merge schemas defined at these different levels so that a merged schema can be used to validate the merged configuration.
The text was updated successfully, but these errors were encountered: