From 5df7d9aec202981ff4789aee9cf9aa0bf1e4e776 Mon Sep 17 00:00:00 2001 From: Martin Asquino Date: Tue, 4 Jul 2017 01:05:09 -0300 Subject: [PATCH] added isSubset rule --- lib/match/rules.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/match/rules.js b/lib/match/rules.js index 4197100..64a097a 100644 --- a/lib/match/rules.js +++ b/lib/match/rules.js @@ -122,6 +122,7 @@ module.exports = { 'maxLength' : function (x, max) { return validator.isLength(x, 0, max); }, 'regex' : function (x, regex) { return validator.matches(x, regex); }, - 'notRegex' : function (x, regex) { return !validator.matches(x, regex); } + 'notRegex' : function (x, regex) { return !validator.matches(x, regex); }, + 'isSubset': function (x, array) { return _.isArray(x) && x.length === _.intersection(x, array).length; } };