-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
[FEAT] Native pydantic support #91
Comments
That sounds neat. To clarify though, is there a specific ask here? I've not used Pydantic at all and I've only just recently started using type annotations in my Python code but have yet to start using them in this project in particular. |
The ask is to natively support Pydantic by adding the pydantic schema methods ( |
That sounds cool. I like the idea of offering optional integrations with other popular libraries. I'm planning on doing something similar with SQLAlchemy eventually so I can get type info for my ORM models. |
@zeroSteiner Thanks for creating this lib and found how easy to write rule are in english. This might be slightly related to this PR, however I am looking to understand from regular user of Pydantic Classes: I trying to write
so, how can I create
1.1 I tried to set type 1.2 What type can be set for |
Unfortunately, there are two things that are unsupported by what you're trying to do.
|
Hola! Working with some rules now that I'm loading from markdown front-matter. To parse / validate the front-matter I'm using Pydantic (v2). During parsing, I wanted to natively transform a string field containing a
rule-engine
rule to aRule
class object. Here's the approach I took:The
PydanticRule
takes a generic type parameter that is used to define the schema supplied toContext
whenRule
is instantiated. This allows the benefit of syntax/symbol error detection when the rule is compiled (read into the pydantic model) instead of at runtime.I think it's a good idea to leave pydantic out of this lib (unless folks really need it). However, it may make sense to create a separate lib that contains the types so rule-engine can be used this way.
Also, we'd probably want to spend more time on the pydantic/python -> rule-engine type conversion. I haven't fully tested that yet.
The text was updated successfully, but these errors were encountered: