Function: ensure()¶
ensure\<
T>(value,guard,options?):T
Validate a value and return it typed, or throw TypeError.
Use when you need the validated value as a typed return.
Type Parameters¶
T¶
T
Parameters¶
value¶
unknown
Value to validate
guard¶
Flame\<T>
Type guard to apply
options?¶
Optional context for error messages
Returns¶
T
The same value as value, typed as T (no conversion is performed)
Throws¶
TypeError if the guard returns false
Example¶
TypeScript
const name = ensure(input, FlameGuards.isString, { at: "processRow", label: "name" });
Logger.log(name.toUpperCase()); // name is typed as string
Since¶
0.37.0