-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Implement pydantic validators for string format checks #406
Comments
@zzstoatzz hi yes! this what do we need to implement for it. but i am a bit afraid to apply it to all existing models. suspect perf degradation. for example in firehose. so it would be great to make this regex validation optional. and the devs could enable it when they want to implement some server side |
that makes sense! I updated the example to make use of validation context for opt-in strict mode, which incurs a small penalty for existing and then a bit more for being enabled
fwiw in prefect we made a |
@zzstoatzz it looks amazing! you did a really good job. do you want to do a PR? i see the PR like this:
|
@MarshalX cool! I've opened #451 but I'm not sure exactly how I should be plugging into / updating the codegen here - pointers welcome! I tried » ipython
In [1]: from atproto_codegen.models.generator import generate_models
In [2]: generate_models() which appeared to update |
@zzstoatzz thank you! After changing the codegen, you need to run it and commit that changes in models as well. CI checks that you do not forgot do to it :) To run codegens we have CLI. CMD: |
@MarshalX excellent! thank you for the direction 🙂 I've marked the PR ready - I'll keep an eye out for a review |
lexicon`s string type has the "type" field which directs strict string pattern https://atproto.com/specs/lexicon
here is the list of these formats (https://atproto.com/specs/lexicon#string-formats):
We could make our model validation more strict. For someone who wants to use SDK`s models from the server side. To implement PDS, for example.
snarfed implemented this string validations and kindly shared with us: https://github.com/snarfed/lexrpc/blob/41a858c2c28ad212df64f347270c3a8092743f1b/lexrpc/base.py#L439-L522
the code above is licensed under CC0 1.0 Universal
I see this task as:
The text was updated successfully, but these errors were encountered: