From 33f556efbb252d8ad2b9879c7d9f0385faea173c Mon Sep 17 00:00:00 2001 From: David Windell Date: Tue, 26 Mar 2013 16:23:56 +0000 Subject: [PATCH] Allow specification of error message via Factory --- library/Zend/InputFilter/Factory.php | 3 +++ tests/ZendTest/InputFilter/FactoryTest.php | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/library/Zend/InputFilter/Factory.php b/library/Zend/InputFilter/Factory.php index 91daf76db65..ee5194fed07 100644 --- a/library/Zend/InputFilter/Factory.php +++ b/library/Zend/InputFilter/Factory.php @@ -153,6 +153,9 @@ public function createInput($inputSpecification) $input->setRequired(!$value); } break; + case 'error_message': + $input->setErrorMessage($value); + break; case 'fallback_value': $input->setFallbackValue($value); break; diff --git a/tests/ZendTest/InputFilter/FactoryTest.php b/tests/ZendTest/InputFilter/FactoryTest.php index 26e0235c87f..8e5c2708e71 100644 --- a/tests/ZendTest/InputFilter/FactoryTest.php +++ b/tests/ZendTest/InputFilter/FactoryTest.php @@ -428,4 +428,14 @@ public function testFactoryAcceptsCollectionInputFilter() $this->assertInstanceOf('Zend\InputFilter\InputFilter', $inputFilter->getInputFilter()); $this->assertEquals(3, $inputFilter->getCount()); } + + public function testFactoryWillCreateInputWithErrorMessage() + { + $factory = new Factory(); + $input = $factory->createInput(array( + 'name' => 'foo', + 'error_message' => 'My custom error message', + )); + $this->assertEquals('My custom error message', $input->getErrorMessage()); + } }