Skip to content
Merged
Changes from 1 commit
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
23 changes: 23 additions & 0 deletions lib/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,31 @@ 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(
'Invalid JSON-LD syntax; a @reverse term definition must not ' +
'contain @id.', 'jsonld.SyntaxError',
{code: 'invalid reverse property', context: localCtx});
}
if('@nest' in value) {
throw new JsonLdError(
'Invalid JSON-LD syntax; a @reverse term definition must not ' +
'contain @nest.', 'jsonld.SyntaxError',
{code: 'invalid reverse property', context: localCtx});
}
const reverse = value['@reverse'];
if(!_isString(reverse)) {
throw new JsonLdError(
Expand Down Expand Up @@ -442,6 +460,10 @@ api.createTermDefinition = (activeCtx, localCtx, term, defined) => {
mapping['@language'] = language;
}

if('@next' in value) {

}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing something here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have been removed, and should have been @nest for a different branch.


// disallow aliasing @context and @preserve
const id = mapping['@id'];
if(id === '@context' || id === '@preserve') {
Expand Down Expand Up @@ -807,6 +829,7 @@ api.isKeyword = v => {
case '@index':
case '@language':
case '@list':
case '@nest':
case '@omitDefault':
case '@preserve':
case '@requireAll':
Expand Down