oxygenxml / blog

Oxygen XML Editor Blog Posts
4 stars 12 forks source link

Before or after the fact validation #5

Open raducoravu opened 4 years ago

raducoravu commented 4 years ago

Converted from internal issue EXM-38781.

Discuss about these different types of validation: before and after the content is inserted.

An answer I gave some time ago:

All the automatic validation that we do is "after the fact" validation, validation which is performed on the current state of the edited document.
Because it may take a while on large documents validation is done on a separate parallel thread in order not to block the user from editing so we cannot block the user interaction with the keyboard (for example user types "a" and we need to validate an entire document before inserting "a" in the document).

I'm thinking about this particular case, I've filled forms which add these restrictions recently and I would find it very frustrating if the application rejected my input. For example I may paste a small fragment of text from some place else. I know the text is too long but after I paste I want to review the entire short description and make it shorter.

We have Java-based API which could be used to intercept editing events from the end user and maybe reject the event if it would make the document not valid in a way. So if you want to try this approach I could try to give you some hints, the checks would no longer use Schematron but you could have similar Java-implemented rules.

In the meantime maybe you can report the overflow of the shortdesc as an error and also in the Preferences->"Editor / Open/Save" page we have a "Check errors on save" checkbox which your writers could check in order to be notified before save that there are still problems in the document.