title: How could Symfony2 forms be used to validate data loaded from a file?
body: <p>From the <a href="http://symfony.com/doc/current/cookbook/doctrine/registration_form.html" rel="nofollow">Symfony2 manual</a>, here is the way a form is validated:</p>
  
  <pre><code>use Symfony\Component\HttpFoundation\Request;
  
  public function createAction(Request $request)
  {
      $em = $this-&gt;getDoctrine()-&gt;getManager();    
      $form = $this-&gt;createForm(new RegistrationType(), new Registration());    
      $form-&gt;handleRequest($request);
  
      if ($form-&gt;isValid()) {
          $registration = $form-&gt;getData();    
          $em-&gt;persist($registration-&gt;getUser());
          $em-&gt;flush();    
          return $this-&gt;redirect(...);
      }    
      return $this-&gt;render(
          'AcmeAccountBundle:Account:register.html.twig',
          array('form' =&gt; $form-&gt;createView())
      );
  }
  </code></pre>
  
  <p>The bottom line is we have an entity <code>Registration</code> and a corresponding form <code>RegistrationType</code>. When we want to validate the data in the <code>$request</code> we use <code>$form-&gt;handleRequest($request);</code></p>
  
  <p>I wanna use the same approach, but when my entities are loaded from a file not posted via a form.</p>
  
  <p>For example I have a <a href="http://en.wikipedia.org/wiki/Comma-separated_values" rel="nofollow">CSV</a> file that has a list of 100 users that I want to create accounts for, but the data needs to be validated the same way the form was validated and an array of errors can be extracted from the form class.</p>
  
  <p>Is there a way to do this automatically using Symfony2 in a similar way?</p>