I have a legacy Java monolithic web application. My goal is to use React on the frontend, keep Java on the backend and add an API for the frontend to use.
My question is how can I write the data validation just once, using it on both the frontend for form validation and on the backend for data validation?
With the API written in java and the data validation written in javascript, is a workable solution to have an intermediate validation proxy API written in javascript+nodejs which then passes validated requests to the java API?
React(js validation) -> nodejs-API(js validation) -> Java-API(no data validation)
Best Answer
Two points:
While they both do "validate" the document:
Just to get this to work, as you've just pointed out, you would need to:
That is a high price to pay for de-duplicating just 2000 lines of code.