I remember being on a pr�ject once where the frontend validation was: when the user stops typing, send the user input to an API that will return an error if there are problems with it.
Can you say more how this is bad? I’m a noob. Isn’t this what some sites do where they display, say, your password strength as you type so that you can stop adding complexity once you get the “strong password” sign?
It took about half a second in-between the user no longer typing and the error message to show up because we were waiting for the server to tell us the user's input had a problem.
I just didn't like how that looked.
EDIT: should clarify this was a while ago and we just POSTed to a server. Nowadays, probably with sockets the speed shouldn't be an issue. Though I still don't think we should've bothered the server with a task the user's computer could do on its own.
You can do that without sending an API call, my guess is all of the logic to check “when the user stops typing”, sending an API call each time, etc just gets very messy and isn’t the best user experience
Tbh I am not mad with this method, the amount of tickets I have received due to misaligned validation on front & backend are just too many.
My team found an edge case in the backend code once validating some input configuration, now we return 400 bad request on a specific config set. Tickets still come in from users that attempt to update their old resources and get our validation messages as the frontend doesn't validate that field if it doesn't change.
For our specific case, this was a while ago so I might be misremembering, but iirc the front and backend code was in one repository, and the validation was just a bunch of regex. So I felt if we were a little careful then misaligning stuff shouldn't be likely.
But yeah having just backend check everything would be safer.
640
u/24NAMANJN Sep 05 '24
A back end developer would delegate this front end saying, please don’t allow anything beyond fixed set of characters 😂