anandrajneesh / decision-engine

Nodejs Rule Engine
https://anandrajneesh.github.io/decision-engine/
MIT License
12 stars 4 forks source link

Support for regex in String comparisons #12

Closed anandrajneesh closed 7 years ago

anandrajneesh commented 7 years ago

Add a new comparator regex in comparators. This should work only for string datatypes, for now engine would not enforce any data typing on the input, it is the responsibility of client. Though test cases should document the behaviour of regex comparator with unsupported data types.

anandrajneesh commented 7 years ago

pattern is converted to a RegExp object using new RegExp(arg) constructor. RegExp.test will work on all the datatypes as long as they are converted to proper strings. Refer ECMA-6 specs for more details. So for clients giving inputs different than strings regex will still hold if pattern matches.

anandrajneesh commented 7 years ago

Implemented in v1.2.0