gorules / zen

Open-source Business Rules Engine for your Rust, NodeJS, Python or Go applications.
https://gorules.io
MIT License
667 stars 61 forks source link

Support for input data validation #167

Open bala-pitchuka opened 1 month ago

bala-pitchuka commented 1 month ago

Hi,

Just want to check if there is an existing mechanism to check that all mandatory fields are provided to zen engine without missing during evaluation.

like a sample rule if threshold > 23 then HOLD

if threshold is not provided as input to zen then them some validation error need to be thrown

Also how to check the json is a valid jdm json before execution currently facing following issue when run, just want to eliminate such issues during rule jdm json creation itself

RuntimeError: {"type":"NodeError","nodeId":"","source":"Graph did not halt. Missing output node."}

thnks

stefan-gorules commented 6 days ago

Hi @bala-pitchuka,

We have some initial plans of looking into type-safety in the future. Our foundation will rest on a dynamic language - ZEN Expressions that will be enhanced with type support at some point.

For now, most common pattern is to do validation of the data before sending it to the rules engine. Depending on the language used, there are some great options: Zod (TypeScript), Validator (Go), validator (Rust crate), etc.