Skip to content

Commit 086b2b8

Browse files
Copilotrotu
andauthored
chore: clarify optional field errors
Agent-Logs-Url: https://github.com/rotu/structview/sessions/0716fb80-af23-468f-86bd-27d35fdca170 Co-authored-by: rotu <119948+rotu@users.noreply.github.com>
1 parent 7092d9b commit 086b2b8

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

fields.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ function resolveBooleanFieldValue(
7575
): boolean {
7676
const result = resolveFieldValue(struct, value)
7777
if (typeof result !== "boolean") {
78-
throw new TypeError("present must resolve to a boolean")
78+
throw new TypeError(
79+
"optional field presence condition must resolve to a boolean",
80+
)
7981
}
8082
return result
8183
}
@@ -421,7 +423,7 @@ export function optional<T>(
421423
const getter = field.get
422424
if (typeof getter !== "function") {
423425
throw new TypeError(
424-
"optional() requires a field descriptor with a getter function",
426+
"optional() requires a field descriptor with a defined 'get' method",
425427
)
426428
}
427429
const presenceConfig = typeof present === "object"

0 commit comments

Comments
 (0)