private function validateArgument(OutputInterface $output, $name, $value, $constraints)
{
if (strlen($value)) {
$errors = $this->validateValue($name, $value, $constraints);
if ($errors->count() > 0) {
$output->writeln('<error>' . $errors[0]->getMessage() . '</error>');
} else {
return $value;
}
}
$question = '<question>' . ucfirst($name) . ': </question>';
$value = $this->askAndValidate($output, $question, function ($inputValue) use($constraints, $name) {
$errors = $this->validateValue($name, $inputValue, $constraints);
if ($errors->count() > 0) {
throw new InvalidArgumentException($errors[0]->getMessage());
}
return $inputValue;
});
return $value;
}