josdejong / josdejong/jsoneditor

Change Json schema validation error message

Open
#1,448 1 comment 0 reactions 0 assignees View on GitHub
question
Dominant language
JavaScript
Stars
12.3k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

Hello,

Is there a way to change the validation error message instead of using the default message? Here is what I have tries so far:

```
onValidationError: function (errors) {
console.debug(errors)
errors.forEach((error) => {
switch (error.type) {
case 'validation': // schema validation error
if(error.schemaPath === "someIdentifier") {
error.message = "Custom Message";
}
break;
case 'customValidation': // custom validation error
break;
case 'error': // json parse error
break;
}
});

},
```

The custom message is not reflected in the json editor. Any help would be appreciated!

Thank you!

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.