title: Symfony2 Asset GreaterThan didn't work
body: <p>I have an issue actually.
  The property "Quantity" in Invetory entity should not be negative.</p>
  
  <p>So I try to use the GreaterThan or GreaterThanOrEqual assert in my entity declaration.</p>
  
  <p>In fact, I can validate negative quantities. 
  I don't understand.</p>
  
  <p>The Entity :</p>
  
  <pre><code>/* src/Clicproxy/***Bundle/Entity/Inventory.php */
  &lt;?php
  
  namespace Clicproxy\***Bundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  use Symfony\Component\Validator\Constraints as Assert;
  
  
  /**
   * Inventory
   *
   * @ORM\Table()
   * @ORM\Entity(repositoryClass="Clicproxy\***Bundle\Entity\InventoryRepository")
   * @UniqueEntity(fields="audit, name", message="entity.inventory.unique")
   */
  class Inventory
  {
      /* [...] */
  
      /**
       * @var integer
       *
       * @ORM\Column(name="quantity", type="integer", nullable=true)
       * @Assert\GreaterThan(value = 1)
       */
      private $quantity;
  
  [...]
  </code></pre>
  
  <p>The FormType : </p>
  
  <pre><code>/* src/Clicproxy/***Bundle/Form/InventoryCollabType.php */
  &lt;?php
  
  namespace Clicproxy\***Bundle\Form;
  
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\OptionsResolver\OptionsResolverInterface;
  
  class InventoryCollabType extends AbstractType
  {
          /**
       * @param FormBuilderInterface $builder
       * @param array $options
       */
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder
              -&gt;add('quantity', null, array('label' =&gt; 'entity.inventory.quantity'))
              -&gt;add('pageCostBlack', null, array('label' =&gt; 'entity.inventory.pagecostblack'))
              -&gt;add('pageCostColor', null, array('label' =&gt; 'entity.inventory.pagecostcolor'))
              -&gt;add('avMonthPagesBlack', null, array('label' =&gt; 'entity.inventory.avmonthpagesblack'))
              -&gt;add('avMonthPagesColor', null, array('label' =&gt; 'entity.inventory.avmonthpagescolor'))
          ;
      }
  
      /* [...] */
  }
  </code></pre>
  
  <p>The Controller :</p>
  
  <pre><code>public function configAction (Request $request, $slug)
  {
      $em = $this-&gt;getDoctrine()-&gt;getManager();
      $audit = $em-&gt;getRepository('Clicproxy***Bundle:Audit')-&gt;findOneBy(array('slug' =&gt; $slug));
  
      if (!$audit instanceof Audit) {
          throw $this-&gt;createNotFoundException('wizard.config.notfound');
      }
  
      $audit-&gt;addInventoriesFromEquipments($em-&gt;getRepository('Clicproxy***Bundle:Equipment')-&gt;findBy(array(), array('optimized' =&gt; 'ASC', 'name'=&gt; 'ASC')));
  
      $form = $this-&gt;createCreateConfigForm($audit);
  
      $form-&gt;handleRequest($request);
  
      if ($form-&gt;isValid()) {
          $em = $this-&gt;getDoctrine()-&gt;getManager();
          $em-&gt;persist($audit);
          foreach ($audit-&gt;getInventories() as $inventory) {
              $inventory-&gt;setAudit($audit);
              $em-&gt;persist($inventory);
          }
          $em-&gt;flush();
  
          /* [...] */
  
          return $this-&gt;redirect($this-&gt;generateUrl('wizard_result', array('slug' =&gt; $audit-&gt;getSlug())));
      }
  
      /* [...] */
  
      return array(
          'audit' =&gt; $audit,
          'form'   =&gt; $form-&gt;createView(),
          'tabactive' =&gt; 2,
      );
  }
  </code></pre>
  
  <p>Does anyone have an idea about my context ?</p>
  
  <p>Thanks for your support,
  David.</p>
  
  <p>EDIT : 
  Finaly I've write this code below, your opinion ?</p>
  
  <pre><code>public function configAction (Request $request, $slug)
  {
      $em = $this-&gt;getDoctrine()-&gt;getManager();
      $audit = $em-&gt;getRepository('Clicproxy***Bundle:Audit')-&gt;findOneBy(array('slug' =&gt; $slug));
  
      if (!$audit instanceof Audit) {
          throw $this-&gt;createNotFoundException('wizard.config.notfound');
      }
  
      $audit-&gt;addInventoriesFromEquipments($em-&gt;getRepository('Clicproxy***Bundle:Equipment')-&gt;findBy(array(), array('optimized' =&gt; 'ASC', 'name'=&gt; 'ASC')));
  
      $form = $this-&gt;createCreateConfigForm($audit);
  
      $form-&gt;handleRequest($request);
  
      if ($form-&gt;isValid()) {
          $validator = $this-&gt;get('validator');
          $errors_messages = array();
          foreach ($audit-&gt;getInventories() as $inventory)
          {
              $violations = $validator-&gt;validate($inventory);
              if (0 &lt; $violations-&gt;count()) 
              {
                  $error_message = substr($violations, strpos($violations, ':')+2);
                  if (! in_array($error_message, $errors_messages, true)) {
                      $errors_messages[] = $error_message;
                      $this-&gt;get('session')-&gt;getFlashBag()-&gt;add('error', $error_message);
                  }
  
              }
          }
          if (! $this-&gt;get('session')-&gt;getFlashBag()-&gt;has('error'))
          {
              $em = $this-&gt;getDoctrine()-&gt;getManager();
              $em-&gt;persist($audit);
              foreach ($audit-&gt;getInventories() as $inventory) {
                  $inventory-&gt;setAudit($audit);
                  $em-&gt;persist($inventory);
              }
              $em-&gt;flush();
  
              /* [...] */
  
              return $this-&gt;redirect($this-&gt;generateUrl('wizard_result', array('slug' =&gt; $audit-&gt;getSlug())));
          }
      }
  
  
      return array(
          'audit' =&gt; $audit,
          'form'   =&gt; $form-&gt;createView(),
          'tabactive' =&gt; 2,
      );
  }
  </code></pre>
  
  <p>Thanks for your support.</p>