p4bloch / console-validable-question
Easily Validate Questions in Symfony/Console
Installs: 19
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
pkg:composer/p4bloch/console-validable-question
Requires
- php: >=5.4.0
- symfony/console: 2.*
This package is not auto-updated.
Last update: 2025-10-21 08:43:21 UTC
README
#ValidableQuestion Easily validate a Symfony/Console Question.
Usage
$question = new ValidableQuestion('Who are you?', ['required']); $question = new ValidableQuestion('How old are you?', ['numeric'], 25); $question = new ValidableQuestion('Enter your e-mail', ['required', 'email']); $helper->ask($input, $output, $question);
Why?
Validating a Question in Symfony/Console involves calling setValidator on each Question and passing the function that will actually validate it as an argument, which is awesome when you need to do a somehow complex validation, but quite annoying when you simply want to check if the value is not null, or a number, or an e-mail, etc.
ValidableQuestion extends Console's Question, but validates the answer against any rules specified in the background, leaving you with a nice and readable one liner.