Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
"./rules/dialect.json",
"./rules/identifiers.json",
"./rules/jsonld-bare-override.json",
"./rules/jsonld-constants-iri-literal.json",
"./rules/jsonld-constants-lexical.json",
"./rules/jsonld-constants-reserved-type.json",
"./rules/jsonld-datatype-reserved.json",
"./rules/jsonld-unmarked-null.json",
"./rules/jsonld-value-rdf-type.json",
"./rules/license.json",
"./rules/links.json",
"./rules/single-line-text.json",
Expand Down
6 changes: 6 additions & 0 deletions rules/jsonld-bare-override.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
},
{
"required": [ "x-jsonld-self" ]
},
{
"required": [ "x-jsonld-value" ]
},
{
"required": [ "x-jsonld-constants" ]
}
]
}
Expand Down
60 changes: 60 additions & 0 deletions rules/jsonld-constants-iri-literal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "std/jsonld_constants_iri_literal",
"description": "A bare string in a constants fragment is always a string literal, so a string that looks like an IRI is almost certainly a node reference missing its id member",
"properties": {
"x-jsonld-constants": {
"additionalProperties": {
"allOf": [
{
"$ref": "#/$defs/term"
},
{
"if": {
"type": "array"
},
"then": {
"items": {
"$ref": "#/$defs/term"
}
}
}
]
}
}
},
"$defs": {
"term": {
"allOf": [
{
"not": {
"type": "string",
"pattern": "^([A-Za-z][A-Za-z0-9+.-]*://|urn:|mailto:|did:|tag:)"
}
},
{
"not": {
"type": "object",
"not": {
"anyOf": [
{
"required": [ "@type" ]
},
{
"required": [ "@language" ]
}
]
},
"required": [ "@value" ],
"properties": {
"@value": {
"type": "string",
"pattern": "^([A-Za-z][A-Za-z0-9+.-]*://|urn:|mailto:|did:|tag:)"
}
}
}
}
]
}
}
}
133 changes: 133 additions & 0 deletions rules/jsonld-constants-lexical.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "std/jsonld_constants_lexical",
"description": "A constant typed literal whose value sits outside the lexical space of its datatype converts to an ill-typed literal that RDF implementations must accept, so this is the only place to catch it",
"properties": {
"x-jsonld-constants": {
"additionalProperties": {
"allOf": [
{
"$ref": "#/$defs/term"
},
{
"if": {
"type": "array"
},
"then": {
"items": {
"$ref": "#/$defs/term"
}
}
}
]
}
}
},
"$defs": {
"term": {
"allOf": [
{
"if": {
"type": "object",
"required": [ "@value", "@type" ],
"properties": {
"@value": {
"type": "number"
},
"@type": {
"$ref": "#/$defs/integer-datatypes"
}
}
},
"then": {
"properties": {
"@value": {
"multipleOf": 1
}
}
}
},
{
"if": {
"type": "object",
"required": [ "@value", "@type" ],
"properties": {
"@value": {
"type": "string"
},
"@type": {
"$ref": "#/$defs/integer-datatypes"
}
}
},
"then": {
"properties": {
"@value": {
"pattern": "^[+-]?[0-9]+$"

@augmentcode augmentcode Bot Aug 3, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

integer-datatypes includes constrained derived types like xsd:nonNegativeInteger/xsd:unsignedByte, but the current lexical check (^[+-]?[0-9]+$ + multipleOf: 1) doesn't enforce those sign/range restrictions. As a result, invalid constants like {"@type":"…#nonNegativeInteger","@value":"-1"} would still satisfy this rule.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

}
}
}
},
{
"if": {
"type": "object",
"required": [ "@value", "@type" ],
"properties": {
"@value": {
"type": "string"
},
"@type": {
"const": "http://www.w3.org/2001/XMLSchema#decimal"
}
}
},
"then": {
"properties": {
"@value": {
"pattern": "^[+-]?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)$"
}
}
}
},
{
"if": {
"type": "object",
"required": [ "@value", "@type" ],
"properties": {
"@value": {
"type": "string"
},
"@type": {
"const": "http://www.w3.org/2001/XMLSchema#boolean"
}
}
},
"then": {
"properties": {
"@value": {
"enum": [ "true", "false", "1", "0" ]
}
}
}
}
]
},
"integer-datatypes": {
"enum": [
"http://www.w3.org/2001/XMLSchema#integer",
"http://www.w3.org/2001/XMLSchema#long",
"http://www.w3.org/2001/XMLSchema#int",
"http://www.w3.org/2001/XMLSchema#short",
"http://www.w3.org/2001/XMLSchema#byte",
"http://www.w3.org/2001/XMLSchema#nonNegativeInteger",
"http://www.w3.org/2001/XMLSchema#nonPositiveInteger",
"http://www.w3.org/2001/XMLSchema#negativeInteger",
"http://www.w3.org/2001/XMLSchema#positiveInteger",
"http://www.w3.org/2001/XMLSchema#unsignedLong",
"http://www.w3.org/2001/XMLSchema#unsignedInt",
"http://www.w3.org/2001/XMLSchema#unsignedShort",
"http://www.w3.org/2001/XMLSchema#unsignedByte"
]
}
}
}
42 changes: 42 additions & 0 deletions rules/jsonld-constants-reserved-type.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "std/jsonld_constants_reserved_type",
"description": "A langString literal requires a language tag that only the language member can provide, and a JSON literal cannot be a constant, so neither IRI is a usable value object type",
"properties": {
"x-jsonld-constants": {
"additionalProperties": {
"allOf": [
{
"$ref": "#/$defs/term"
},
{
"if": {
"type": "array"
},
"then": {
"items": {
"$ref": "#/$defs/term"
}
}
}
]
}
}
},
"$defs": {
"term": {
"not": {
"type": "object",
"required": [ "@type" ],
"properties": {
"@type": {
"enum": [
"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#JSON"
]
}
}
}
}
}
}
15 changes: 15 additions & 0 deletions rules/jsonld-datatype-reserved.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "std/jsonld_datatype_reserved",
"description": "A langString literal requires a language tag that only x-jsonld-language can provide, and a JSON literal is declared with x-jsonld-json, so neither IRI is a usable datatype",
"properties": {
"x-jsonld-datatype": {
"not": {
"enum": [
"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#JSON"
]
}
}
}
}
16 changes: 16 additions & 0 deletions rules/jsonld-unmarked-null.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,22 @@
"type": "null"
}
}
},
{
"required": [ "x-jsonld-value" ],
"properties": {
"x-jsonld-value": {
"type": "null"
}
}
},
{
"required": [ "x-jsonld-constants" ],
"properties": {
"x-jsonld-constants": {
"type": "null"
}
}
}
]
},
Expand Down
12 changes: 12 additions & 0 deletions rules/jsonld-value-rdf-type.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "std/jsonld_value_rdf_type",
"description": "The rdf:type predicate as a value predicate would mint type edges to literals, and node types are declared with x-jsonld-type",
"properties": {
"x-jsonld-value": {
"not": {
"const": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
}
}
}
}
Loading