Skip to main content
Version: v0.0.8

Function: renderCallerValue()

renderCallerValue(value): string

Render a caller-supplied value as a bounded, quoted fragment for a build* refusal message. This is the only sanctioned route a caller value takes into a thrown message, and test/builder-refusal-bounds.test.ts scans src/ for any other route - a twenty-fourth refusal site that interpolates a value directly reds that test. That scan keys on throw new *BuildError( and on template-literal holes, so it is a strong tripwire for the shape this library uses rather than a proof over every shape one could write.

Returns the value quoted when it fits, and otherwise the first BUILD_REFUSAL_VALUE_MAX_LENGTH characters, an ellipsis, and the true length - the length is the diagnostically useful part when the value is over-long, since that is usually why the builder refused.

Parameters

value

string | number

Returns

string

Example

import { renderCallerValue } from "@cosyte/x12";
renderCallerValue("000000001"); // '"000000001"'
renderCallerValue("9".repeat(120000)); // '"999…" (120000 characters)'