isBindingId

See source code

Type guard to check if a string is a valid TLBindingId. Validates that the ID follows the correct format for binding identifiers.

function isBindingId(id?: string): id is TLBindingId

Example

// Validate binding IDs
const maybeBindingId = 'binding:abc123'
if (isBindingId(maybeBindingId)) {
  // maybeBindingId is now typed as TLBindingId
  const binding = store.get(maybeBindingId)
}

// Filter binding IDs from mixed ID array
const mixedIds = ['shape:1', 'binding:2', 'page:3']
const bindingIds = mixedIds.filter(isBindingId)

Parameters

NameDescription

id

string

The string to check

Returns

id is TLBindingId

True if the string is a valid binding ID, false otherwise

Prev
isBinding
Next
isDocument