validateChannelId static method

bool validateChannelId(
  1. String id
)

Returns true if the given id is a valid channel id.

Implementation

static bool validateChannelId(String id) {
  if (id.isNullOrWhiteSpace) {
    return false;
  }

  if (!id.startsWith('UC')) {
    return false;
  }

  if (id.length != 24) {
    return false;
  }

  return !RegExp(r'[^0-9a-zA-Z_\-]').hasMatch(id);
}