inputWithValidation method

  1. @override
String inputWithValidation({
  1. String prompt = 'input',
  2. required String? validator(
    1. String p1
    ),
  3. Object? defaultValue,
})
override

Implementation

@override
String inputWithValidation({
  String prompt = 'input',
  required String? Function(String p1) validator,
  Object? defaultValue,
}) {
  while (true) {
    final result = input(prompt: prompt, defaultValue: defaultValue);

    final validatorError = validator(result);

    if (validatorError == null) {
      return result;
    }

    logger.err(validatorError);

    logger.spaces();
  }
}