src/validator.js
function matchGroups(groupsConfig, wantedGroups)
    {
        var defaultGroups = ['default'];
        var groups = _.map([groupsConfig, wantedGroups], function(grp) {
            if (_.isUndefined(grp)) {
                return defaultGroups;
            } else if (_.isString(grp)) {
                return [grp];
            } else if (_.isArray(grp)) {
                return grp;
            }else if (_.isFunction(grp)) {
                var r = grp();
                if (_.isString(r)) {
                    return [r];
                } else if (_.isArray(r)) {
                    return r;
                }
            }
            return defaultGroups;
        });
        return _.intersection(groups[0], groups[1]).length > 0;
    }
function matchGroups(groupsConfig, wantedGroups)
    {
        var defaultGroups = ['default'];
        var groups = _.map([groupsConfig, wantedGroups], function(grp) {
            if (_.isUndefined(grp)) {
                return defaultGroups;
            } else if (_.isString(grp)) {
                return [grp];
            } else if (_.isArray(grp)) {
                return grp;
            }else if (_.isFunction(grp)) {
                var r = grp();
                if (_.isString(r)) {
                    return [r];
                } else if (_.isArray(r)) {
                    return r;
                }
            }
            return defaultGroups;
        });
        return _.intersection(groups[0], groups[1]).length > 0;
    }
function matchGroups ( groupsConfig , wantedGroups ) { var defaultGroups = [ 'default' ] ; var groups = _ . map ( [ groupsConfig , wantedGroups ] , function ( grp ) { if ( _ . isUndefined ( grp ) ) { return defaultGroups ; } else if ( _ . isString ( grp ) ) { return [ grp ] ; } else if ( _ . isArray ( grp ) ) { return grp ; } else if ( _ . isFunction ( grp ) ) { var r = grp ( ) ; if ( _ . isString ( r ) ) { return [ r ] ; } else if ( _ . isArray ( r ) ) { return r ; } } return defaultGroups ; } ) ; return _ . intersection ( groups [ 0 ] , groups [ 1 ] ) . length > 0 ; }
Given 2 lists of groups, return true if the two groups lists share common groups and false otherwise
Return the default group if the group value is invalid
@param  array groupsConfig The first groups list
@param  array wantedGroups The second groups list
@return boolean true if groups lists match
Given 2 lists of groups return true if the two groups lists share common groups and false otherwise Return the default group if the group value is invalid