-
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
Using "str: object" to allow and ignore unrecognized fields defeats validation of Optional fields #57
Comments
Just ran
Thanks for fixing! Any sense of how long before we can expect a release with the fix? And any sense for how stable latest P.S. In the process of testing this I hit #90 -- hope that PR helps. |
Oh, just noticed #59, good to read a new release sounds imminent. Will follow that issue to find out when it happens. In the meantime, would love to know if anyone had a chance to check out the related code I linked to above. If there's anything schema can use from that, I'd be happy to try to facilitate that. @keleshev @skorokithakis @sjakobi @kosz85 et al. |
@jab I like your nice and simple interface. Thought this schema has simple interface too. I love to work with attributes like in your solution (as it's more natural), but I myself would use it as proxy or wrapper for schema and not as feature of main schema object. Attrs have many constrictions if we talk about their names, so not for everyone it's fully usable. You would need to add some auto-mapping (and manual too) for keys with spaces and special chars. But in future I would love to see such proxy also in this project, but probably as smth separate. |
@jab That is indeed a very nice, simple interface. I think it's a bit limited in that you can't easily specify subschemas (you have to compose them with other classes, which is a bit verbose), but it's a nice alternative. I don't think it does the same thing as this package (this package is more for imposing schemas on data, yours is for imposing schemas on classes), so I think both have their place in a project. I don't think they're interchangeable, or even very related in the ways they'll be used. |
Thanks for taking a look. Just to clear up some misunderstandings,
Nope, those work fine:
Nope, mine is for data, you misunderstood. |
Use case: A schema may contain some optional fields that should be validated if present. Unrecognized fields should be allowed and ignored.
The docs say that unrecognized fields may be allowed and ignored by including
str: object
in the schema. However, this defeats the validation of any Optional fields:Is this behavior intentional or is this a bug?
Thanks for any attention to this and for releasing schema.
P.S. I cranked out some one-off code to do schema validation in a side project years ago that I never separated out and released as its own module. It's still up on GitHub at https://github.com/jab/SiCDS/blob/master/sicds/schema.py in case there's anything there you'd like to incorporate into this project. Looks like I released that code GPLv3 but if you'd require another license I could certainly relicense it.
The text was updated successfully, but these errors were encountered: