simple-interface
Create interfaces to validate objects. It's so simple, probably doesn't support the fancy thing you are looking for.
What?
While developing some state modeling, having an interface system to validate objects makes things easier to reason about:
const PostInterface = const post = title: 'foo' body: 'bar' PostInterface // => true
It doesn't try to solve every use case, but since the check to see if a value satisfies the assigned interface value in an object is really easy (simply compares object's constructor to see it matches the corresponding value in the interface definition), it should cover most of your use cases.
// custom class {} const ClassInterface = const obj = klass: ClassInterface // => true
You can use other interfaces as interface values.
const FooInterface = const BarInterface = BarInterface// => true BarInterface// => BarInterface { foo: FooInterface { title: String } }
install
npm install simple-interface
licence
MIT