You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
Is there an easy way to assert a structure that has some required fields and some optional fields. And have it fail if there are any other unknown fields.
This works but I'm just wondering if there is a better way:
exportdefaultclassDirective{constructor(options: DirectiveOptions){this.selector=options.selector;this.bind=options.bind;}}varDirectiveOptions=assert.define('DirectiveOptions',function(options){//Required fieldsassert(options).is(assert.structure({selector: assert.string}));//Optional fieldsif(options.bind){assert.type(options.bind,Object);}for(varkeyinoptions){if(options.hasOwnProperty(key)){if(key!=='selector'&&key!=='bind'){assert.fail(`${key} is not a valid directive field`);}}}});
On an unrelated note any idea what I need to use assert.string instead of just string. I'm transpiling with Traceur 0.0.74.