Description
When a value fails schema validation (e.g., an invalid type value), the diagnostic from/to positions point to the colon (:) after the property key, rather than the actual invalid value.
Reproduction
Schema:
{
"type": "object",
"properties": {
"type": {
"anyOf": [
{ "enum": ["object", "array", "string", "number", "integer", "boolean", "null"] },
{ "type": "array", "items": { "enum": ["object", "array", "string", "number", "integer", "boolean", "null"] } }
]
}
}
}
Document being validated:
Expected
The error marker should highlight "objectd" (positions 12–21).
Actual
The diagnostic reports from: 10, to: 11, which is the : character after "type".
{"type": "objectd"}
^
position 10-11 (colon highlighted)
Console output from forEachDiagnostic:
{
message: 'Value `objectd` at `type` does not match any schema...',
severity: 'error',
from: 10,
to: 11,
source: 'json-schema'
}
Analysis
In validation.js, the positioning logic uses pointer.valueFrom / pointer.valueTo for non-positional errors (line 137-138). The pointer values appear to be off by one — landing on the separator rather than the value.
Environment
codemirror-json-schema: 0.8.1 (latest)
@uiw/react-codemirror wrapper
Related: #158 (also about incorrect error marker positions)
Description
When a value fails schema validation (e.g., an invalid
typevalue), the diagnosticfrom/topositions point to the colon (:) after the property key, rather than the actual invalid value.Reproduction
Schema:
{ "type": "object", "properties": { "type": { "anyOf": [ { "enum": ["object", "array", "string", "number", "integer", "boolean", "null"] }, { "type": "array", "items": { "enum": ["object", "array", "string", "number", "integer", "boolean", "null"] } } ] } } }Document being validated:
{"type": "objectd"}Expected
The error marker should highlight
"objectd"(positions 12–21).Actual
The diagnostic reports
from: 10, to: 11, which is the:character after"type".Console output from
forEachDiagnostic:Analysis
In
validation.js, the positioning logic usespointer.valueFrom/pointer.valueTofor non-positional errors (line 137-138). The pointer values appear to be off by one — landing on the separator rather than the value.Environment
codemirror-json-schema: 0.8.1 (latest)@uiw/react-codemirrorwrapperRelated: #158 (also about incorrect error marker positions)