validateTTB static method
Accepts a string which represents the MillisecondsSinceEpoch
Returns ttlMs
which is time_to_birth in MilliSecondsSinceEpoch
Method ensures ttb
has a valid value
Implementation
static int validateTTB(String? ttb) {
int ttbMs = 0;
if (ttb == null || ttb.trim().isEmpty) {
return ttbMs;
}
try {
ttbMs = int.parse(ttb);
} on FormatException {
throw InvalidSyntaxException(
'Valid value for TTB should be greater than or equal to 0');
}
// TTB cannot have a negative value.
if (ttbMs < 0) {
throw InvalidSyntaxException(
'Valid value for TTB should be greater than or equal to 0');
}
return ttbMs;
}