RunKit + npm: superstruct

node v8.17.0
endpointsharetweet
var superstruct = require("superstruct") const User = superstruct.struct({ id: 'number', name: 'string', }) const Article = superstruct.struct({ id: 'number', title: 'string', author: User, }, { author: { id: 1000, name: 'Owner', }, }) const article1 = Article({ id: 1, title: 'This works as expected', author: { id: 2, name: 'Contributor', }, }) console.log(article1.author) const article2 = Article({ id: 1, title: 'This does not work!', }) console.log(article2.author)
Created from: https://npm.runkit.com/superstruct
Loading…