Frontend: normalize and display server validation errors

13378
0

Server-side validation is the source of truth, but raw error payloads are rarely UI-friendly. I normalize validation errors into a Record<field, message> shape so forms can render them consistently. The tricky detail is mapping server field paths to form field names, especially for nested inputs. I also handle non-validation errors separately so the form can show a top-level banner. This keeps UX consistent: field errors show near inputs, and generic failures show once. Once there’s a standard mapping utility, every form benefits and you avoid copy/paste logic that drifts as the backend adds new rules.