Skip to content

Commit

Permalink
Allow specification of error message via Factory
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwindell committed Mar 26, 2013
1 parent b11af3f commit 33f556e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/Zend/InputFilter/Factory.php
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions tests/ZendTest/InputFilter/FactoryTest.php
Expand Up @@ -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());
}
}

0 comments on commit 33f556e

Please sign in to comment.