Skip to content

Instantly share code, notes, and snippets.

@JoshuaEstes
Created October 9, 2015 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshuaEstes/0ef82116e842b4b1173d to your computer and use it in GitHub Desktop.
Save JoshuaEstes/0ef82116e842b4b1173d to your computer and use it in GitHub Desktop.
<?php
protected function interact(InputInterface $input, OutputInterface $output)
{
$dialog = $this->getDialogHelper();
$validator = Validation::createValidator();
$inputValue = $dialog->askAndValidate($output, 'Enter some input: ', function($value) use($validator){
$errors = $validator->validateValue($value, new Assert\NotBlank());
if (count($errors)) {
throw new \InvalidArgumentException((string) $errors);
}
return $value;
});
$MoreInputValue = $dialog->askAndValidate($output, 'Enter even more input input: ', function($value) use($validator){
$errors = $validator->validateValue($value, new Assert\NotBlank());
if (count($errors)) {
throw new \InvalidArgumentException((string) $errors);
}
return $value;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment