Hey,
Context
when using Schemasafe for deeply nested data containing invalid data in object contained in array contained in object in an array, the generated error has invalid instanceLocation. This behavior was originally discovered when using Schemasafe within Superforms, see the original issue and with the help of the author, the bug was isolated to Schemasafe.
The problem
This is the data structure in question:
{
type: 'object',
additionalProperties: false,
required: ['arr'],
properties: {
arr: {
type: 'array',
items: {
type: 'object',
additionalProperties: false,
required: ['arr'],
properties: {
arr: {
type: 'array',
items: {
type: 'object',
additionalProperties: false,
properties: {
tryInvalidValue: {
type: 'string',
minLength: 5
}
}
}
}
}
}
}
}
}
Invalid data like this:
{
arr: [
{
arr: [
{
tryInvalidValue: '123'
}
]
}
]
}
Should result in this error:
[
{
keywordLocation: '#/properties/arr/items/properties/arr/items/properties/tryInvalidValue/minLength',
instanceLocation: '#/arr/0/arr/0/tryInvalidValue'
}
]
Instead, Schemasafe generates this error:
[
{
keywordLocation: '#/properties/arr/items/properties/arr/items/properties/tryInvalidValue/minLength',
instanceLocation: '#/arr/0arr/0/tryInvalidValue'
}
]
In words, the item's index in array is concatenated with the object's key, instead of being separated by delimiter.
More details
For demonstration I made a MRE: https://github.com/Hejtmus/schemasafe-MRE-invalid-error-instance-location
Have a nice day!
Hey,
Context
when using Schemasafe for deeply nested data containing invalid data in object contained in array contained in object in an array, the generated error has invalid
instanceLocation. This behavior was originally discovered when using Schemasafe within Superforms, see the original issue and with the help of the author, the bug was isolated to Schemasafe.The problem
This is the data structure in question:
Invalid data like this:
Should result in this error:
Instead, Schemasafe generates this error:
In words, the item's index in array is concatenated with the object's key, instead of being separated by delimiter.
More details
For demonstration I made a MRE: https://github.com/Hejtmus/schemasafe-MRE-invalid-error-instance-location
Have a nice day!