Skip to content

"Not Equal to Nil" kind of check before executing expressions #433

Closed
@alok87

Description

@alok87

hey we wrote a simple rule engine using expr (with when and then)

Problem:
Our users specify rules like show offers if order.Amount > 500 and product.Category = xyz. But at the time offer discovery sometimes order Amount is not available or sometimes product.Category is also not available. But we want to show the offers to those users. So we want to write an expression like:

(order.Amount > 500 || order.Amount == 0) &&
(product.Category == xyz || product.Category == "")  

But doing this for every fact fields (facts are order and product here) is adding un-necessary complexity in writing such rules. As users in API just specify conditions around fact's field. Order's and product's fields. And we make an expression from it internally.

Do you have any suggestion around this problem's solution with expr?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions