jenyaatnow / jenyaatnow/validator4j
Add new validation report format
- Dominant language
- Java
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
We want to add ability to report validation errors in multiple different formats. Currently **validator4j** supports ReportFormat.**PROPERTY_PATH**. We want to add new - ReportFormat.**JSON_MIRROR**.
*Prerequisites:*
We have to validate the following json:
```json
{
"id": null,
"name": "Tom",
"roles": [ "author", null ],
"articles": [
{
"id": 1,
"name": "New article"
},
{
"id": null,
"name": "Another article"
}
]
}
```
Currently implemented ReportFormat.**PROPERTY_PATH** may looks like
```json
{
"errors": [
{
"path": "",
"message": "User info is not valid"
},
{
"path": "id",
"message": "Id should not be null"
},
{
"path": "roles[1]",
"message": "Role should not be null"
},
{
"path": "acticles",
"message": "Article info is not valid"
},
{
"path": "acticles[1].id",
"message": "Id should not be null"
}
]
}
```
ReportFormat.**JSON_MIRROR** should look like this one:
```json
{
"__globalError__": "User info is not valid",
"id": "Id should not be null",
"roles": [ null, "Role should not be null" ],
"articles": [
{ },
{
"__globalError__": "Article info is not valid",
"id": "Id should not be null"
}
]
}
```
Thus ReportFormat.**JSON_MIRROR** format reflects validated object structure, but instead of object values we have error messages for invalid fields. Besides there are additional field "__globalError__" which contains entire object error message.
Contributor guide
Research direction
Start by locating ReportFormat and the implementation of PROPERTY_PATH, then trace how nested validation errors are assembled. Add JSON_MIRROR as a format that preserves the validated object structure and places object-level messages under __globalError__, then verify the output against the examples in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100