В application.ini (или что у тебя)
form.test.title[] = NotEmpty
form.test.title.Regexp.validator = Regex
form.test.title.Regexp.breakChainOnFailure = false
form.test.title.Regexp.options = /\W/
form.test.name[] = NotEmpty
form.test.name[] = Alnum
А потом в коде PHP:
/* The experimental form */
$form = new Zend_Form ();
$form->addElement('text', 'title', array ('label' => 'test1'));
$form->addElement('text', 'name', array ('label' => 'test2'));
$form->addElement('submit', 'submit');
/* Zend_Registry::get('config') is where I keep my application.ini after it has been parsed in the Bootstrap */
$config = Zend_Registry::get('config')->form->test;
foreach ($config as $index => $value)
{
if ($value instanceof Zend_Config)
{
foreach ($value as $validator)
{
if (is_string ($validator))
{
$form->$index->addValidator ($validator);
}
else
{
$form->$index->addValidators (array ($validator->toArray ()));
}
}
}
else
{
$form->$index->addValidator ($value);
}
}