Skip to content

Commit 90ceb38

Browse files
committed
docs(coerce): describe the zero-sentinel rule by its contract
The comment justified the min>0 guard with edit's occurrence as the 0-indexed example, but occurrence became 1-based in the v0.49 surface change and no caller passes min=0 today. Describing the rule by the field's accepted domain keeps it true as callers change.
1 parent 90a28bd commit 90ceb38

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

packages/aft-bridge/src/coerce.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,8 @@ export function coerceOptionalInt(
166166
max: number,
167167
): number | undefined {
168168
if (v === undefined || v === null || v === "") return undefined;
169-
// 0 is an empty-param sentinel ONLY when 0 is out of bounds anyway. For
170-
// 0-indexed params (edit's `occurrence`, min=0) it is the most common legal
171-
// value — dropping it sent agents into an ambiguous_match loop that told
172-
// them to pass the param they had just passed.
169+
// 0 is an empty-param sentinel only when 0 is outside the field's accepted
170+
// domain. Fields whose contract permits zero must retain it for validation.
173171
if (typeof v === "number" && (!Number.isFinite(v) || (v === 0 && min > 0))) return undefined;
174172
const n = typeof v === "string" ? Number(v) : v;
175173
if (typeof n !== "number" || !Number.isInteger(n)) {

0 commit comments

Comments
 (0)