UNPKG

explicit

Version:

System to explicitly specify the way a method works.

20 lines (17 loc) 503 B
'use strict' const validate = require('./index')(require('../schema/definition')) module.exports = pluginMap => definition => { if (typeof definition !== 'object' || definition === null || definition === undefined) { return { $one: true, _raw: true, _rawContent: definition } } definition = validate(definition) for (const plugin of pluginMap) { const field = `$${plugin.name}` definition[field] = plugin.validate(definition[field]) } return definition }