mvolf commented on PR #1085:
URL: https://github.com/apache/camel-karavan/pull/1085#issuecomment-1913511445

   > @mvolf thank for the contribution. This Validator on backend and and yup 
on frontend with dosens lines of code just to simply check if file is already 
exists. Look like an overkill. Should it be that complex?
   
   Thanks for the comments @mgubaidullin.
   I personally don't see this as complex or as an overkill. Validation is one 
of the most important parts of the system, since it ensures data 
validity/consistency and makes the system less prone to serious bugs.
   In this example I don't look at this as "simply check if file already 
exists", but as potential consequences if this kind of validation is not 
implemented properly through out the whole system (as we've seen this results 
in overwriting of users existing file).
   
   This kind of approach also follows several best approaches:
   * back-end should always do the validation (preferably service method). In 
this way validation is enforced across the system where ever this method is 
called. Validation is also enforced if API is called manually, which bypasses 
any front-end validation.
   * validation error messages are a part of the back-end validator and are 
shown on the front-end. This makes translation of these messages fairly easy to 
implement if needed.
   * additional front-end validation (in our case using react-hook-form and 
yup) is added for presenting users with certain validation messages while 
typing, to speed up the flow and unburden back-end by avoiding unnecessary API 
calls.
   * implementation of the validation is uniform and follows the same 
principles, where implementing validation differently for every page depending 
on the needs makes the code less clear and harder to maintain
   
   These are some of the main points, but there are several more benefits.
   If you look more closely to this implementation and compare it to the 
existing you'll notice that there's not that much code more and in my opinion 
the benefits far outweigh a bit more lines of the code.
   
   I hope that I managed to present you my point of view :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to