diff --git a/lib/context.js b/lib/context.js index 2a11055e..98bb02a9 100644 --- a/lib/context.js +++ b/lib/context.js @@ -260,6 +260,18 @@ api.createTermDefinition = (activeCtx, localCtx, term, defined) => { const mapping = activeCtx.mappings[term] = {}; mapping.reverse = false; + // make sure term definition only has expected keywords + const validKeys = ['@container', '@id', '@language', '@reverse', '@type']; + + for(let kw in value) { + if(!validKeys.includes(kw)) { + throw new JsonLdError( + 'Invalid JSON-LD syntax; a term definition must not contain ' + kw, + 'jsonld.SyntaxError', + {code: 'invalid term definition', context: localCtx}); + } + } + if('@reverse' in value) { if('@id' in value) { throw new JsonLdError(