Skip to content
RED SAGSkills
easyFull Stack Developer interview question

In a web app with a React frontend and an API, where should input validation happen, and why?

What the interviewer wants to hear

  • Client-side validation is for fast feedback and better UX
  • Server-side validation is required because clients can be bypassed
  • Database constraints are the last line of defense
  • Sharing one schema keeps rules consistent across tiers
  • Return clear field-level errors the UI can display

Model answer

I validate in three places, each for a different reason. In the browser I validate for user experience, so people see mistakes immediately without a round trip. On the server I validate every request again, because anyone can skip the form and call the API with curl or a script; the server is the real security boundary. Finally, the database has constraints like NOT NULL, UNIQUE, foreign keys and CHECK rules, which protect data even if a bug slips through the application code. In a TypeScript project I like to define one schema, for example with Zod, and use it in both the form and the API handler, so limits and messages never drift. When validation fails the API returns a 400 or 422 with field-level errors, and the form shows each message next to the right input.

Can you answer it under time pressure?

Take a timed easy round and get scored on every answer.

Start mock interview

More easy Full Stack Developer questions