Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save davemackintosh/c23389471a7d5d7743d5ec1c93d7d5ac to your computer and use it in GitHub Desktop.
Save davemackintosh/c23389471a7d5d7743d5ec1c93d7d5ac to your computer and use it in GitHub Desktop.
"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