question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Show validation errors when calling validate() method

See original GitHub issue

How can I show validation errors for inputs when calling validate() method?


I tried using editor.trigger("change") and set show_errors: "change", but it doesn’t work.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
jdorncommented, Oct 6, 2014

I added a setOption method. I don’t think I want to add a showErrors method at this time, but it should be easy enough to add yourself:

JSONEditor.prototype.showErrors = function() {
  this.setOption('show_errors','always');
}
JSONEditor.prototype.hideErrors = function() {
  this.setOption('show_errors','never');
}
1reaction
mazswojejzonycommented, Sep 16, 2014

To me show_errors controls automatic validation and errors visualization. validate() method makes on demand, application triggered validation possible (but without errors visualization).

What is missing is the on demand, application triggered validation and errors visualization.

I believe this is a typical workflow (@IonicaBizau please comment if this is more or less the same in your case):

  1. User navigates to the configuration screen.
  2. Several options are shown using JSON Editor, including editor for array of objects.
  3. User adds additional (say third) object to the array by clicking “Add Item” button.
  4. JSON Editor shows third object properties with default values set as expected. One field is empty (there is no default value) however according to the schema this one field cannot be empty to validate the JSON value.
  5. User clicks “Save” button.

After step no.5 application has to trigger validation and show which field values are missing or incorrect.

This is what is missing right now and I still believe adding a new method for this purpose should not really complicate anything. Changing options to achieve this effect is a not the best solution in my opinion. It may be the way to implement the new method but I think it should be hidden from JSON Editor clients.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Show Validation Error Messages for Reactive Forms in ...
Show Validation Error Messages for Reactive Forms in Angular 9 · Show the Field is Required Using the Label · Show the Validation...
Read more >
How to show validation errors in laravel api while having a ...
I think that's not possible, but you can use the prepareForValidation() method within you FormRequest and manipulate data before validate.
Read more >
A Better Way to Handle Validation Errors - Kevin Smith
Another common technique is to bundle up all the validation errors and return them in some sort of payload—an array, a custom Errors...
Read more >
Display Server Side Validation Errors with Angular - | juri.dev
By using an async validator, we can call a function on the server via an API to verify whether the user provided value...
Read more >
Build a form with validation - Flutter documentation
When the validate() method is called, it runs the validator() function for each text field in the form. If everything looks good, the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found