inputWithValidation method

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

Implementation

@override
String inputWithValidation({
  String prompt = 'input',
  required String? Function(String) 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();
  }
}