Normalizes an empty/whitespace dropdown or input value to `undefined`, otherwise a trimmed string.
(value: unknown)
| 26 | |
| 27 | /** Normalizes an empty/whitespace dropdown or input value to `undefined`, otherwise a trimmed string. */ |
| 28 | function optionalString(value: unknown): string | undefined { |
| 29 | if (value === undefined || value === null) return undefined |
| 30 | const trimmed = String(value).trim() |
| 31 | return trimmed.length > 0 ? trimmed : undefined |
| 32 | } |
| 33 | |
| 34 | /** Coerces a 'true'/'false' dropdown value to boolean, or `undefined` when unset. */ |
| 35 | function optionalBoolean(value: unknown): boolean | undefined { |
no outgoing calls
no test coverage detected