MCPcopy Index your code
hub / github.com/simstudioai/sim / parseOptionalBooleanInput

Function parseOptionalBooleanInput

apps/sim/blocks/utils.ts:516–547  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

514 * Returns `undefined` for empty or unrecognized values.
515 */
516export function parseOptionalBooleanInput(value: unknown): boolean | undefined {
517 if (value === undefined || value === null || value === '') {
518 return undefined
519 }
520
521 if (typeof value === 'boolean') {
522 return value
523 }
524
525 if (typeof value === 'number') {
526 return value !== 0
527 }
528
529 if (typeof value !== 'string') {
530 return undefined
531 }
532
533 const normalized = value.trim().toLowerCase()
534 if (normalized.length === 0) {
535 return undefined
536 }
537
538 if (normalized === 'true' || normalized === '1') {
539 return true
540 }
541
542 if (normalized === 'false' || normalized === '0') {
543 return false
544 }
545
546 return undefined
547}
548
549const DEFAULT_MULTIPLE_FILES_ERROR =
550 'File reference must be a single file, not an array. Use <block.files[0]> to select one file.'

Callers 6

utils.test.tsFile · 0.90
codepipeline.tsFile · 0.90
shopify.tsFile · 0.90
video_generator.tsFile · 0.90
trello.tsFile · 0.90
image_generator.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected