Skip to content

Commit

Permalink
Fix zendframework#69 - Use attached NotEmpty message when required va…
Browse files Browse the repository at this point in the history
…lidation fails
  • Loading branch information
larsnystrom committed Oct 7, 2015
1 parent af8837d commit 4fc84cd
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,20 @@ protected function injectNotEmptyValidator()
*/
protected function prepareRequiredValidationFailureMessage()
{
$notEmpty = new NotEmpty();
$chain = $this->getValidatorChain();
$validators = $chain->getValidators();

foreach ($validators as $validator) {
if ($validator['instance'] instanceof NotEmpty) {
$notEmpty = $validator['instance'];
break;
}
}

if (!isset($notEmpty)) {
$notEmpty = new NotEmpty();
}

$templates = $notEmpty->getOption('messageTemplates');
return [
NotEmpty::IS_EMPTY => $templates[NotEmpty::IS_EMPTY],
Expand Down

0 comments on commit 4fc84cd

Please sign in to comment.