Added joi plugin validation

This commit is contained in:
Wyatt Johnson
2017-04-06 10:39:36 -06:00
parent e70cfdfd00
commit 1f367e666b
10 changed files with 54 additions and 0 deletions
+3
View File
@@ -1,4 +1,5 @@
const _ = require('lodash');
const Joi = require('joi');
const debug = require('debug')('talk:graph:mutators');
const Comment = require('./comment');
@@ -17,6 +18,8 @@ let mutators = [
// Load the plugin mutators from the manager.
...plugins
.get('server', 'mutators').map(({plugin, mutators}) => {
Joi.assert(mutators, Joi.object().pattern(/\w/, Joi.object().pattern(/\w/, Joi.func())), `Plugin '${plugin.name}' had an error loading the mutators`);
debug(`added plugin '${plugin.name}'`);
return mutators;