validate method
This method is called by ask to valiate the string entered by the user. It should throw an AskValidatorException if the input is invalid. The validate method is called when the user hits the enter key. If the validation succeeds the validated line is returned.
Implementation
@override
String validate(String line) {
assert(
version == either || version == ipv4 || version == ipv6,
'The version nmust be AskValidatorIPAddress.either or '
'AskValidatorIPAddress.ipv4 or AskValidatorIPAddress.ipv6',
);
final finalline = line.trim();
if (!isIP(finalline, version)) {
throw AskValidatorException(red('Invalid IP Address.'));
}
return finalline;
}