function IOInterface::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.
Parameters
string $question The question to ask:
callable $validator A PHP callback:
null|int $attempts Max number of times to ask before giving up (default of null means infinite):
mixed $default The default answer if none is given by the user:
Return value
mixed
Throws
\Exception When any of the validators return an error
2 methods override IOInterface::askAndValidate()
- ConsoleIO::askAndValidate in vendor/
composer/ composer/ src/ Composer/ IO/ ConsoleIO.php - @inheritDoc
- NullIO::askAndValidate in vendor/
composer/ composer/ src/ Composer/ IO/ NullIO.php - @inheritDoc
File
-
vendor/
composer/ composer/ src/ Composer/ IO/ IOInterface.php, line 172
Class
- IOInterface
- The Input/Output helper interface.
Namespace
Composer\IOCode
public function askAndValidate(string $question, callable $validator, ?int $attempts = null, $default = null);