title: Possible to create a factory to instantiate custom Form validators?
body: <p>(using Zend Framework 2.2.4)</p>
  
  <p>My validator factory, doesn't seem to "exist" at validation time.  If I attempt to instantiate the validator from the controller in which the form is housed, it conversely works fine:</p>
  
  <p><strong>This works...</strong></p>
  
  <pre><code>$mycustomvalidator = $this-&gt;getServiceLocator()
      -&gt;get('ValidatorManager')
      -&gt;get('LDP_PinAvailable');
  </code></pre>
  
  <p>Here's how things are set up otherwise in the code, I can't seem to find the problem, and was hopeful to avoid opening up ZF2 source to understand.  By way of documentation, it seems right.</p>
  
  <p><strong>Module Config</strong></p>
  
  <pre><code>public function getValidatorConfig()
  {
      return array(
         'abstract_factories' =&gt; array(
             '\LDP\Form\Validator\ValidatorAbstractFactory',
         ),
      );
  }
  </code></pre>
  
  <p><strong>Factory Class</strong></p>
  
  <pre><code>namespace LDP\Form\Validator;
  
  use Zend\ServiceManager\AbstractFactoryInterface,
      Zend\ServiceManager\ServiceLocatorInterface;
  
  class ValidatorAbstractFactory implements AbstractFactoryInterface
  {
      public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
      {
          return stristr($requestedName, 'LDP_PinAvailable') !== false;
      }
  
  
      public function createServiceWithName(ServiceLocatorInterface $locator, $name, $requestedName)
      {
          // baked in for sake of conversation
          $validator = new \LDP\Form\Validator\PinAvailable();
  
          if( $validator instanceof DatabaseFormValidatorInterface )
              $validator-&gt;setDatabase( $locator-&gt;get('mysql_slave') );
  
          return $validator;
      }
  }
  </code></pre>
  
  <p><strong>Custom Validator</strong></p>
  
  <pre><code>namespace LDP\Form\Validator;
  
  class PinAvailable extends \Zend\Validator\AbstractValidator implements DatabaseFormValidatorInterface
  {
  
      /**
       * @var \Zend\Db\Sql\Sql
       */
      private $database;
  
      public function setDatabase( \Zend\Db\Sql\Sql $db )
      {
          $this-&gt;database = $db;
      }
  
  
      public function isValid( $value )
      {
          $DBA = $this-&gt;database-&gt;getAdapter();
          // do the mixed database stuff here
          return true;
      }
  }
  </code></pre>
  
  <p>Lastly, the form field validator config part of the array:</p>
  
  <pre><code>'pin' =&gt; array(
      'required' =&gt; true,
          'filters'  =&gt; array(
              array('name' =&gt; 'alnum'),
              array('name' =&gt; 'stringtrim'),
          ),
          'validators' =&gt; array(
              array( 'name' =&gt; 'LDP_PinAvailable' )
          ),
      ),
  ),
  </code></pre>
  
  <p>Piecing it all together, the form loads, and when submitted, it does with the stack trace below:</p>
  
  <pre><code>2013-10-28T17:09:35-04:00 ERR (3): Exception:
  1: Zend\Validator\ValidatorPluginManager::get was unable to fetch or create an instance for LDP_PinAvailable
  Trace:
  #0 /Users/Saeven/Documents/workspace/Application/vendor/zendframework/zendframework/library/Zend/ServiceManager/AbstractPluginManager.php(103): Zend\ServiceManager\ServiceManager-&gt;get('LDP_PinAvailabl...', true)
  #1 /Users/Saeven/Documents/workspace/Application/vendor/zendframework/zendframework/library/Zend/Validator/ValidatorChain.php(82): Zend\ServiceManager\AbstractPluginManager-&gt;get('LDP_PinAvailabl...', Array)
  </code></pre>