code: static void checkId(String id) {
      if (!ID.matcher(id).matches()) {
        throw new IllegalArgumentException(String.format("not a valid js identifier: %s", id));
      }
    }
docs: Validates that the given string is a valid javascript identifier.