code: function restrictItemsTo(opts) {
    if (!opts) {
      throw new InvalidRestrictionOpts('you did not pass any opts to restrictItems');
    }
    if (!opts.collection) {
      throw new InvalidRestrictionOpts('you did not specify an opts with a collection in it');
    }
    if (!opts.restrictToSchema) {
      throw new InvalidRestrictionOpts('you did not specify an opts with a restricting schema');
    }
    var s = _.cloneDeep(opts.collection);
    if (!s.patternProperties) {
      throw new InvalidRestrictionOpts('collection is not a collection with patternProperties');
    }
    _.each(_.keys(s.patternProperties), function(key) {
      s.patternProperties[key] = {
        allOf: [
          s.patternProperties[key],
          opts.restrictToSchema
        ]
      };
    });
    if (opts.required) {
      if (!s.required) s.required = [];
      s.required = _.union(s.required, opts.required);
      if (s.required.length < 0) delete s.required; // 'required' has to have at least one element
    }
    return s; 
  }
docs: Turns out any documents which contain data want to be able to specify the kind of data keys you'd expect to find in it's data objects.  This function conveniently lets you take an existing schema for a collection of data objects, and restrict each one to make the original schema AND the restricted schema passed in. opts: - collection: original collection's schema to restrict - restrictToSchema: new schema to limit original schema with - required: an additional list of required keys