-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement an onValidation callback #56
Comments
Thanks for your question. The In your codesandbox, you can produce an error by:
Are there cases where you would expect an error which is not fired? |
Ah, that is an interesting idea. It would not be the onError: in the application, a parse error is just a "validation error", similar to validation warnings when you have configured a JSON schema. It would be neat to implement an |
Thinking this scenario: |
@loliconer That pretty much is my scenario and would work well for me. Another approach would be to pass along |
That is an interesting idea. Instead of passing an extra parameter An other idea would be to expose a function onSave() {
const content = editor.get()
const issues = editor.validate()
const isValid = issues.length === 0
// ...
} Would that make sense? EDIT: that would be a non-declarative solution though, requiring a reference to the editor |
@josdejong I prefer the first solution, as |
I agree that a list makes a lot more sense than |
Let's go for the following solution, giving all flexibility you may ever need:
|
Available now in |
@josdejong It seems there's no way to replace the default error handling behaviour with a custom on? This feature gives me the errors but the error box is still shown. |
@VitorTS I'm not sure what you mean. There is an |
I may be understanding the functionality of the
onError
callback function, but I would assume that it would be triggered on a JSON error.This does not seem to work today, at least not when using it in React.
I've replicated it here in a fork of the React example: https://codesandbox.io/s/svelte-jsoneditor-react-forked-3ohvvk
The text was updated successfully, but these errors were encountered: