@pcvl/schema / coerceToString
Function: coerceToString()
ts
function coerceToString(value): unknown;Defined in: coercions.ts:25
The conversion pvl.string().coerce() applies before its own check: every input becomes its String() form, so the string check always passes — including for undefined, null and objects, which become 'undefined', 'null' and '[object Object]'. Chain .optional() or .nullable() before .coerce() to keep undefined or null as they are.
Parameters
value
unknown
Returns
unknown
Example
ts
import { coerceToString } from '@pcvl/schema';
coerceToString(42); // '42'
coerceToString(true); // 'true'
coerceToString(undefined); // 'undefined'