Created
August 29, 2016 10:49
-
-
Save davemackintosh/c23389471a7d5d7743d5ec1c93d7d5ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict" | |
const Joi = require("joi") | |
const my_class_schema = require("./schema") | |
class Interface { | |
constructor() { | |
// Get the members on this class. | |
const class_funcs = Object.getOwnPropertyNames(Object.getPrototypeOf(this)) | |
const class_as_object = {} | |
// Create an object from those methods so we can validate their arity. | |
class_funcs.forEach(func => class_as_object[func] = this[func]) | |
my_class_schema.validate(class_funcs) | |
if (validation.error) { | |
return Promise.reject(validation.error) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment