requireString()function
requireString(value: PossibleString, caller: AnyCaller = requireString): string
| Param | Type | |
|---|---|---|
value | PossibleString | The value to convert. required |
caller | AnyCaller | Function to attribute a thrown error to (defaults to requireString). Defaults to requireString |
| Return | |
|---|---|
string | The string representation of value. |
| Throws | |
|---|---|
RequiredError | If value cannot be converted to a string. |
Convert a possible string to a string, or throw RequiredError if conversion fails.
Examples
requireString(123) // "123"