CoolFace
Apppublic

strong-tie/inbound-calls

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
validate-plugin.js27 linesDownload Raw Back to lib
1'use strict'2 3const { AVV_ERR_PLUGIN_NOT_VALID } = require('./errors')4 5/**6 * @param {any} maybePlugin7 * @throws {AVV_ERR_PLUGIN_NOT_VALID}8 *9 * @returns {asserts plugin is Function|PromiseLike}10 */11function validatePlugin (maybePlugin) {12  // validate if plugin is a function or Promise13  if (!(maybePlugin && (typeof maybePlugin === 'function' || typeof maybePlugin.then === 'function'))) {14    if (Array.isArray(maybePlugin)) {15      throw new AVV_ERR_PLUGIN_NOT_VALID('array')16    } else if (maybePlugin === null) {17      throw new AVV_ERR_PLUGIN_NOT_VALID('null')18    } else {19      throw new AVV_ERR_PLUGIN_NOT_VALID(typeof maybePlugin)20    }21  }22}23 24module.exports = {25  validatePlugin26}27