-
Notifications
You must be signed in to change notification settings - Fork 2
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
pydantic for validation #71
Comments
I've looked at this and I don't think it's something we can use, unless we bend over backwards. What pydantic doespydantic can be used to validate data based on a model In principle, this is exactly what we want to do, but we have additional design requirements that, I think are hard to fit in the pydantic way of doing things. This is an example copy-pasted from their documentation:
here I have a model for our How I intended to use pydanticI intended to transform parselglossy into a code generator:
this command would give:
The validation models would have been generated à la pydantic, see example above. I think having a generator is better:
Why we can't use pydanticWe have two powerful mechanisms for defaulting and validation that I do not want to get rid of:
The need to have the input tree available when computing defaults and checking predicates, effectively bars us from using pydantic. I can see no way to get the tree as an additional parameter Conclusionsa. I am pretty much convinced that we need to transform this tool into a code generator, for the reasons given above. |
Thank you! Both conclusions are convincing to me. |
There exists this neat library https://pydantic-docs.helpmanual.io that could help us with validation. At a glance, the advantage seems to be that defining new data types is equivalent to adding a class with decorated methods. This could certainly help in making parselglossy customizable and possibly to solve #51. The disadvantage is that this requires Python 3.6+
The text was updated successfully, but these errors were encountered: