Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down