Knetic / govaluate

Arbitrary expression evaluation for golang
MIT License
3.73k stars 498 forks source link

Partial evaluation #144

Open faxal opened 4 years ago

faxal commented 4 years ago

Please refer to https://github.com/casbin/casbin/issues/545 for details of the issue

Is that something can be implemented or is it possible as it stands today?

TLDR

When an expression cannot be evaluated, return the unevaluated expression as a result.

Given this expression: role == 'Admin' && age > 18 && age < 60

Assuming role == 'Admin' is true but age > 18 && age < 60 cannot be evaluated, return result as

true && age > 18 && age < 60

or even better

age > 18 && age < 60

faxal commented 4 years ago

The use case is to evaluate expressions from two different sources of truth. In the above example, role == 'Admin' is known during expression evaluation, but age > 18 && age < 60 cannot be evaluated as source information is available elsewhere like an SQL database.

This allows user to further evaluate the expression elsewhere, burden is on the user to evaluate after that, not the library.

spotandjake commented 3 years ago

pls add this, this would make my life a lot easier