Add live validations to React editor.

Description

The GWT editor runs validations on translations as they are typed, and immediately displays problems detected by the validators.

The React editor should be able to run any of the standard validators, based on the settings for the project-version (off/warning/error).

Validators to be kept in strongly-typed code (Typescript), and prepared as a module to be built through a separate webpack config and entry to generate the Validator library as JavaScript consumable by Nashorn on the server in

List of validators (taken from GWT editor validation options):

  • HTML/XML tags

  • Java variables

  • Leading/trailing newline (\n)

  • Positional printf (XSI extension)

  • Printf variables

  • Tab characters (\t)

  • XML entity reference

Integrate Validators with alpha editor Validation component
Apply Validators selected as Warning / Error in validation option settings

Activity

Show:
Sean Flanigan
September 15, 2016, 2:45 AM
Edited

We have a few options here:

  1. Provide a REST service (on the server) which runs the existing (Java) validations. Note that the cost of sending the text to be validated could be significant, especially for large strings. On the other hand, this might allow us to create new validations which require server-side resources, eg "msgfmt -c".

  2. Call out from JavaScript to GWT to run the existing validations in the browser (using GWT in headless mode to write pure functions). This would take a bit of setting up, but it should have the best all-round performance.

  3. Port all the validations from Java to JavaScript, using them natively in the React editor, but running them in Nashorn on the server (eg TranslationStateCacheImpl), and discarding the old Java versions. This may hurt performance for server-side validations, because Nashorn won't be as fast as native Java.

(It would also be possible to port all the validations from Java to JavaScript, maintaining both the JS version for the browser and the Java version for the server, but of course this is a truly terrible idea.)

Long term, it might also make sense to combine some of the options, eg provide a REST service for special server-side validations, but have other validations which can be run on either browser or server (using either Nashorn or GWT).

In the short term, I think a REST service for validation is our best option for getting a working solution in a reasonable time, while still allowing the validation code to be shared between React and GWT during the transition.

Kathryn Gough
March 6, 2017, 12:51 AM

covers the implementation of the frontend

David Mason
August 30, 2017, 4:48 AM
Edited

Similar to option 2, we could transpile the validation classes to javascript modules and import them into the frontend app the same as any other module. This may be possible with gwt, or something like http://www.jsweet.org

Sean Flanigan
August 30, 2017, 6:10 AM
David Mason
August 30, 2017, 6:19 AM
Ready for Release

Assignee

Earl Mark Floden

Reporter

David Mason

Labels

None

Tested Version/s

None

Story Points

3

Epic Link

Components

Sprint

None

Fix versions

Priority

unspecified
Configure