Symfony\Component\Console\Helper\DialogHelper::askHiddenResponseAndValidate
Asks for a value, hide 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 askHiddenResponseAndValidate(OutputInterface
$output,
[string|array
$question = false,
[callable
$validator = false,
[integer
$attempts = false,
[Boolean
$fallback = true]]]] )
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)
$fallback
— object- In case the response can not be hidden, whether to fallback on non-hidden question or not
Returns
- string
- The response
Errors/Exceptions
-
Exception
- When any of the validators return an error
-
RuntimeException
- In case the fallback is deactivated and the response can not be hidden