I want to share input validation because:
- User experience in frontend, instantly tells the user if the input is good/wrong
- If on localhost, both environments use this module to validate input.
- If in production/preprod, my deployment script copy the module in both frontend and backend before deploying.
- Import code would look like this each time I try to validate an input:
const validator = process.env.ENV === 'local' ? require('../../validator') : require('/validator')
Is there any other widely accepted method to do this (I guess it is a very common problem but I didn't find similar issues)? If not, is my method correct?