You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
450 B
JavaScript

"use strict";
// FIXME: Package separately under @validatem/
const isFunction = require("@validatem/is-function");
const ValidationError = require("@validatem/error");
module.exports = [
isFunction,
(func) => {
let current = func.prototype;
while (current != null) {
if (current === Error.prototype) {
return;
}
current = Object.getPrototypeOf(current);
}
throw new ValidationError(`Must be an error constructor`);
}
];