isValidBindingSlot function

bool isValidBindingSlot(
  1. String value
)

Returns whether value is a stable binding-slot token.

Implementation

bool isValidBindingSlot(String value) {
  if (!RegExp(r'^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$').hasMatch(value)) {
    return false;
  }
  const reserved = {
    'connect',
    'delete',
    'get',
    'head',
    'options',
    'patch',
    'post',
    'put',
    'trace',
  };
  return !reserved.contains(value);
}