Skip to content

Instantly share code, notes, and snippets.

@JoshuaEstes
Created October 9, 2015 19:15
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/8137f4750d8214ee45a4 to your computer and use it in GitHub Desktop.
Save JoshuaEstes/8137f4750d8214ee45a4 to your computer and use it in GitHub Desktop.
<?php
protected function interact(InputInterface $input, OutputInterface $output)
{
$dialog = $this->getDialogHelper();
$inputValue = $dialog->askAndValidate($output, 'Enter some input: ', array($this, 'validateInput'));
}
public function validateInput($value)
{
$validator = Validation::createValidator();
$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