Symfony\Component\Console\Helper\DialogHelper::askAndValidate
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.
Signature
public function askAndValidate(OutputInterface
$output,
[string|array
$question = false,
[callable
$validator = false,
[integer
$attempts = false,
[string
$default = null,
[array
$autocomplete = null]]]]] )
Parameters
$output
— Symfony\Component\Console\Output\OutputInterface- An Output instance
$question
— object- The question to ask
$validator
— object- A PHP callback
$attempts
— integer- Max number of times to ask before giving up (false by default, which means infinite)
$default
— string- The default answer if none is given by the user
$autocomplete
— array- List of values to autocomplete
Returns
- mixed
Errors/Exceptions
-
Exception
- When any of the validators return an error