Skip to content

Commit 1a20556

Browse files
validator/items: fix instanceLocation
1 parent cfca0e3 commit 1a20556

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[
2+
{
3+
"description": "check index in error",
4+
"schema": {
5+
"$schema": "https://json-schema.org/draft/2020-12/schema",
6+
"prefixItems": [
7+
{ "type": "string" },
8+
{ "type": "string" }
9+
],
10+
"items": {
11+
"type": "boolean"
12+
}
13+
},
14+
"tests": [
15+
{
16+
"description": "with fraction",
17+
"data": [ "a", "b", "c" ],
18+
"valid": false,
19+
"errors": [
20+
"at '/2' [S#/items/type]: got string, want boolean"
21+
]
22+
}
23+
]
24+
}
25+
]

validator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ func (vd *validator) arrValidate(arr []any) {
390390
// items2020 --
391391
if s.Items2020 != nil {
392392
for i, item := range arr[evaluated:] {
393-
vd.addErr(vd.validateVal(s.Items2020, item, strconv.Itoa(i)))
393+
vd.addErr(vd.validateVal(s.Items2020, item, strconv.Itoa(evaluated+i)))
394394
}
395395
}
396396
}

0 commit comments

Comments
 (0)