Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 4fc84cd

Browse files
committed
Fix #69 - Use attached NotEmpty message when required validation fails
1 parent af8837d commit 4fc84cd

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Input.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,20 @@ protected function injectNotEmptyValidator()
491491
*/
492492
protected function prepareRequiredValidationFailureMessage()
493493
{
494-
$notEmpty = new NotEmpty();
494+
$chain = $this->getValidatorChain();
495+
$validators = $chain->getValidators();
496+
497+
foreach ($validators as $validator) {
498+
if ($validator['instance'] instanceof NotEmpty) {
499+
$notEmpty = $validator['instance'];
500+
break;
501+
}
502+
}
503+
504+
if (!isset($notEmpty)) {
505+
$notEmpty = new NotEmpty();
506+
}
507+
495508
$templates = $notEmpty->getOption('messageTemplates');
496509
return [
497510
NotEmpty::IS_EMPTY => $templates[NotEmpty::IS_EMPTY],

0 commit comments

Comments
 (0)