Using brij-spec on the client
alexwakeman opened this issue · 3 comments
Hi,
Your node lib / tool is clearly awesome for our needs, in defining business rules in an intuitive and dynamic way.
I would love to be able to use this in the browser, in order to validate views to manage workflows from here. I could do this in node but would like to do it from the client.
Is there a way to do this? I've tried packing the node plugin but there are some native dependencies (from node) that won't export this way.
Would be fantastic to allow this all to work on the client-side as well.
Alex
Since this is just a way to define the rules in JSON, there isn't nothing really stopping you from using this in the client. The validation bits here just make sure that the the rules you have written adhere to the standard and are valid, it does not actually run the rulesets against your data.
The issue then, is writing an engine that can process the rules as defined against your data. This of course can be done within the client side. For an example engine, have a look at https://github.com/cfpb/hmda-rule-engine and specifically, one of the engine mixins that covers the base conditions outlined by brij-spec: https://github.com/cfpb/hmda-rule-engine/blob/master/lib/engineBaseConditions.js
Hope that helps point you in the right direction.
Can you give an example of testing a JavaScript object against the validated rules?
I don't seem to understand at which point I can test real data against the rules spec...
Ok having more carefully looked into it, I can see what you're saying will require more work on my part to run the rules engine. Thanks.