mjhm / lodash-match-pattern

Deep JSON pattern matching library
MIT License
50 stars 3 forks source link

Match one of set of values? #48

Open robross0606 opened 2 years ago

robross0606 commented 2 years ago

How do I match a field that can be any of multiple values, such as from an Enum of possible options? Effectively an "or" pattern?

robross0606 commented 2 years ago

I would have thought of using _.includes but that takes the collection as its first value so I'm not sure how that would work with | syntax.

robross0606 commented 2 years ago

I've gone over everything in here and I'm kinda shocked that there doesn't seem to be built-in way to check if a simple string matches one of a set of values without using Regex. 😮