I'm working on allowing my users to create their own ruleset for data that's coming in. All of the data below is sample mock data and not in relation to our product. Example of a rule (there can be many):
CONDITIONS: (IF) 1) title = 'some*' 2) user = 'john' OUTCOME: (THEN) 1) e-mail me 2) deny request
so in the rule above if a request is made
it would deny the request and e-mail the user since it matches the condition. if the request is
input?title='blah'&user='john' it would allow it to pass since it doesn't match any rules.
I found two ways of doing this but I'm not too happy with it and hoping someone else might have a better solution.
- When a user creates a rule it generates a temp file where it writes that rule into a programming language of IF THEN statements
- When a new request comes in, it goes through that user's rule-list in the programming language and does the appropriate actions
- When a new request comes in, it gets written into a db
- We pull all the conditionals from the db for different rules and run a query against that one row to see if it matches the conditions. If it does, we pass along the outcomes to the script to do the rest
I'm not happy with either of these days. Any insight or help here is much appreciated.