All jobs / Backend developer / API Development
Backend developer interview question · 1–3 years
The interviewer asks: “Where do you validate input?” Strongest answer?
The strongest answer
At the HTTP edge (schema, types, limits) and again as domain rules (this user may not approve their own expense). I never trust the client or a second internal caller by default.
Why it works
Exactly. Edge validation gives cheap 400s. Domain rules belong next to the decision. Defense in depth — DB constraints are the last net, not the first.
What a good answer covers
- Validate at the edge and in the domain.
- Never trust the client.
- DB constraints are a backstop.
- Internal callers are still callers.
Answers that fall short
- Close, but not the strongest: In the frontend — the API can assume the JSON is already clean.
The frontend is a convenience. Anyone can POST. The API is the security boundary. - Weak: Only in the database constraints; the app stays thin.
DB constraints catch some invalid states and miss others (cross-field rules, authz). They're necessary, not sufficient. - Red flag: Skip validation in the internal network; other services are trusted.
“Internal” is where SSRF and a compromised job land. Authenticate and validate service-to-service too.
Who gets asked this
More API Development questions
- The interviewer asks: “PUT versus PATCH?” Strongest answer?
- The interviewer asks: “How should API errors look to clients?” Strongest answer?
- The interviewer asks: “How do you version a public JSON API?” Strongest answer?
- When would you pick gRPC over a JSON REST API, and what do you give up?
- Your OpenAPI document lists every path and method and nothing else. A partner team says integrating still…
- The interviewer asks: “You're building an internal platform API other teams will live on. What changes?”…
- The interviewer asks: “When do you use GET versus POST?” Strongest answer?
- The interviewer asks: “What's the difference between HTTP 401 and 403?” Strongest answer?