ajv-validator / ajv-validator/ajv

Error message from strict schema validation does not contain whole path

Open
#2,545 0 comments 0 reactions 0 assignees View on GitHub
bug report
Dominant language
TypeScript
Stars
14.8k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

**What version of Ajv are you using? Does the issue happen if you use the latest version?**
Latest version (8.17.1)

**Ajv options object**

```javascript
const ajvOptions = {
unicodeRegExp: false,
allErrors: true,
strict: 'log',
allowUnionTypes: true
}
```

**JSON Schema**

```json
{
"$id": "https://example.com/schema/1.0",
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"id": {
"description": "unique ID of this event",
"properties": {}
},
"ref": {
"$ref": "#/definitions/ref"
},
"anotherRef": {
"$ref": "#/definitions/anotherRef"
}
},
"required": [
"id"
],
"definitions": {
"anotherRef": {
"allOf": [
{
"type": "string"
},
{
"properties": {}
}
]
},
"ref": {
"allOf": [
{
"$ref": "#/definitions/anotherRef"
},
{
"properties": {}
}
]
}
}
}
```

**Error messages of strict valdation**

```
strict mode: missing type "object" for keyword "properties" at "https://example.com/schema/1.0#/properties/id" (strictTypes)

strict mode: missing type "object" for keyword "properties" at "https://example.com/schema/1.0#/definitions/anotherRef/allOf/1" (strictTypes)

strict mode: missing type "object" for keyword "properties" at "https://example.com/schema/1.0#/allOf/1" (strictTypes)
```

**What results did you expect?**
Last error message does not contain the whole path, so the user does not know where to look for the mentioned error. Especially with a big schema it can be a problem.

Message should contain whole path and look like:
```
strict mode: missing type "object" for keyword "properties" at "https://example.com/schema/1.0#/definitions/ref/allOf/1" (strictTypes)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.