hoaproject / Ruler

The Hoa\Ruler library.
https://hoa-project.net
625 stars 66 forks source link

Matching values in an Array? #120

Closed prayag-tydy closed 6 years ago

prayag-tydy commented 6 years ago

Hi,

I need to match values in an array. For example:

$rule = "role in ["admin","user","employee']";

$context['role'] = array(''employee","superadmin").

If any of the role given as an array present in the rule then it should return true. Could anyone please help me how can I achieve this?

Hywan commented 6 years ago

Hi :-),

The in operator checks that an item is present in a collection of items. What you want is to check that a list of items are present in a collection. I suggest you to create a new operator to achieve this :-). Check this small documentation https://github.com/hoaproject/Ruler#adding-operators-and-functions, or the official longer documentation to learn how to do that, https://hoa-project.net/En/Literature/Hack/Ruler.html#Add_functions :-).

If you need any help, we are here!

prayag-tydy commented 6 years ago

Hi Hywan. Thank you so much :). It worked. :D