Classes/Console/Mvc/Cli/ConsoleOutput.php
public function askAndValidate($question, $validator, $attempts = false, $default = null, array $autocomplete = null)
    {
        $question = (new Question($question, $default))
            ->setValidator($validator)
            ->setMaxAttempts($attempts)
            ->setAutocompleterValues($autocomplete);

        return $this->getQuestionHelper()->ask($this->getInput(), $this->output, $question);
    }
public function askAndValidate($question, $validator, $attempts = false, $default = null, array $autocomplete = null)
    {
        $question = (new Question($question, $default))
            ->setValidator($validator)
            ->setMaxAttempts($attempts)
            ->setAutocompleterValues($autocomplete);

        return $this->getQuestionHelper()->ask($this->getInput(), $this->output, $question);
    }
Asks for a value and validates the response

The validator receives the data to validate. It must return the
validated data when the data is valid and throw an exception
otherwise.

@param string|array $question The question to ask. If an array each array item is turned into one line of a multi-line question
@param callable $validator A PHP callback that gets a value and is expected to return the (transformed) value or throw an exception if it wasn't valid
@param int|bool $attempts Max number of times to ask before giving up (false by default, which means infinite)
@param string $default The default answer if none is given by the user
@param array $autocomplete List of values to autocomplete. This only works if "stty" is installed
@throws \Symfony\Component\Console\Exception\RuntimeException
@throws \Symfony\Component\Console\Exception\LogicException
@throws \Symfony\Component\Console\Exception\InvalidArgumentException
@return mixed