invalidFormat method
Throws an ArgumentError if input
doesn't match the regexPattern
.
Returns input
otherwise.
Implementation
String invalidFormat(
String input,
String regexPattern, {
String? name,
String? message,
bool caseSensitive = true,
bool multiline = false,
}) {
RegExpMatch? match = RegExp(regexPattern).firstMatch(input);
if (match == null) {
throw ArgumentError.value(
input, name, message ?? 'Input was not in required format');
}
return input;
}