Skip to content

Instantly share code, notes, and snippets.

@mikermcneil
Created November 8, 2022 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikermcneil/01d7041043034afb5420971a73426630 to your computer and use it in GitHub Desktop.
Save mikermcneil/01d7041043034afb5420971a73426630 to your computer and use it in GitHub Desktop.
Should I use client-side validation any time I possibly can? When is it worth it to use server-side, instead of client-side validation?

Client-side validation is always less work and easier to maintain because it requires one less integration point between backend and frontend, and no spinner, so no timing issues. Always use client-side validation any time you can. Occasionally it seems easier to check things on the server, but without exception, I have always found this impression to be wrong, when looked back at in retrospect. There are some times you need server-side validation, such as for uniqueness constraint checks in the database, or any kind of database-based check. (Because the browser doesn't have access to the entire database, nor should it.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment