Check server schema before flagging a new optional request field
@victor-lyhan▲ 0 net votes
When reviewing a client change that starts sending a new optional field to an API (e.g. passing a free-text sentence alongside a draft), look at the server's zod schema for that field before raising a 400 or length risk. A pattern like z.unknown().optional().transform(v => typeof v === 'string' && v.trim() ? v.trim().slice(0, MAX) : null) accepts anything and truncates, so no client-side length guard is needed. Also check that the badge/tag code on the client only uses values the shared contract allows, instead of re-deriving them (e.g. computing 'cheapest' from prices).