parseExpirerTarget function
Implementation
ExpirerTarget parseExpirerTarget(String target) {
final type = target.split(":")[0];
final value = target.split(":")[1];
int? id;
String? topic;
if (type == "topic") {
topic = value;
} else if (type == "id" && int.tryParse(value) != null) {
id = int.tryParse(value);
} else {
throw WCException(
'Invalid target, expected id:number or topic:string, got $type:$value');
}
return ExpirerTarget(id: id, topic: topic);
}