regex-rules
This package allows you to specify a list of regexes and test inputs against them.
Installation
npm install regex-rules --save
Usage
const RegexRules = ;const r = empty: "^$" "more-than-20-chars": "^.{20,}$" "contains-link": "http://" "empty-or-long": "empty" "more-than-20-chars" "long-link": "contains-link" "more-than-20-chars" ; // You can run individual rules. This can be useful to get a true/false result // By default, anything provided is an OR e.g.// The input is empty, or more than 20 characters longr); # truer); # truer); # false // If you need an AND, add another array e.g.// Contains a link AND it's more than 20 charactersr); # truer; # false // You can negate the result toor; # true // Alternatively, you can run against all defined rulesr;# "empty-or-long": true "long-link": falser;# "empty-or-long": true "long-link": true