customError method
Renders the given custom error.
Implementation
String customError(String key, value) {
if (!customErrorMessages.containsKey(key)) {
throw ArgumentError("No custom error message registered for '$key'.");
}
var msg = customErrorMessages[key];
if (msg is String) {
return msg.replaceAll('{{value}}', value.toString());
} else if (msg is CustomErrorMessageFunction) {
return msg(value);
}
throw ArgumentError("Invalid custom error message '$key': $msg");
}