validate static method
Validates a string.
Implementation
static String validate(String value) {
if (value.isEmpty) {
return value;
}
if (value.length < 3) {
throw Exception(
'Invalid account name, must be at least 3 characters long.');
}
for (int pos = 0; pos < value.length; pos++) {
if (pos == 0 && !ALLOWED_START.contains(value[pos])) {
throw Exception(
'Invalid AccountName encoding - character ${value[pos]} not allowed at position ');
} else if (pos > 0 && !ALLOWED_ALL.contains(value[pos])) {
throw Exception(
'Invalid AccountName encoding - character ${value[pos]} not allowed at position $pos');
}
}
return value;
}