title: Symfony Form Type constraint of string validates Integer value
body: <p>I have a simple entity with three fields: an autogenerated ID, a string and an integer. I have set constraints for the latter two, and the constraint corresponding to the integer field works perfectly. If I send an integer which is not in the range, or should I send anything but an integer, then an error is returned.</p>
  
  <p>However that does not happen with the string field. If I send an integer the form validates correctly. Why is that happening?</p>
  
  <p>The code I am using for testing is:</p>
  
  <pre><code>curl -H "Content-Type: application/json" -X POST -d '{"fieldOne": 9000, "fieldTwo": 5}' http://localhost:8000/foos
  </code></pre>
  
  <p><strong>FooController.php</strong></p>
  
  <pre><code>&lt;?php
  
  namespace AppBundle\Controller;
  
  use AppBundle\Entity\FooBar;
  use AppBundle\Form\FooBarType;
  
  use FOS\RestBundle\Controller\FOSRestController;
  use FOS\RestBundle\Request\ParamFetcher;
  use FOS\RestBundle\View\View;
  
  use Symfony\Component\HttpFoundation\Request;
  use Symfony\Component\HttpFoundation\Response;
  
  class FooController extends FOSRestController
  {
  
      public function getFooAction()
      {
          $view = new View();
  
          $data = array(
              'foo' =&gt; 'bar'
          );
  
          $view-&gt;setStatusCode(Response::HTTP_OK);
          $view-&gt;setData($data);
  
          return $view;
      }
  
      public function postFooAction(Request $request)
      {
          $foobar = new FooBar();
          $form = $this-&gt;createForm(FooBarType::class, $foobar);
  
          $data = json_decode($request-&gt;getContent(), true);
          $form-&gt;submit($data);
          if ($form-&gt;isValid()) {
  
              //$foobar = $form-&gt;getData();
  
              $response = new Response('All good');
              $response-&gt;setStatusCode(Response::HTTP_OK);
              return $response;
          }
          return View::create($form, Response::HTTP_BAD_REQUEST);
      }
  
  }
  </code></pre>
  
  <p><strong>FooBarType.php</strong></p>
  
  <pre><code>&lt;?php
  
  namespace AppBundle\Form;
  
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\FormBuilderInterface;
  
  class FooBarType extends AbstractType
  {
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder
              -&gt;add('fieldOne')
              -&gt;add('fieldTwo')
          ;
      }
  }
  </code></pre>
  
  <p><strong>FooBar Entity</strong></p>
  
  <pre><code>&lt;?php
  
  namespace AppBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Symfony\Component\Validator\Constraints as Assert;
  
  /**
   * FooBar
   *
   * @ORM\Table(name="foo_bar")
   * @ORM\Entity(repositoryClass="AppBundle\Repository\FooBarRepository")
   */
  class FooBar
  {
      /**
       * @var int
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @var string
       *
       * @Assert\Type("string")
       * @ORM\Column(name="field_one", type="string", length=255)
       */
      private $fieldOne;
  
      /**
       * @var int
       *
       * @Assert\Range(
       *      min = 1,
       *      max = 10,
       *      minMessage = "You must be at least {{ limit }}cm tall to enter",
       *      maxMessage = "You cannot be taller than {{ limit }}cm to enter"
       * )
       * @ORM\Column(name="field_two", type="int")
       */
      private $fieldTwo;
  
      /**
       * Get id
       *
       * @return int
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * Set fieldOne
       *
       * @param string $fieldOne
       *
       * @return FooBar
       */
      public function setFieldOne($fieldOne)
      {
          $this-&gt;fieldOne = $fieldOne;
  
          return $this;
      }
  
      /**
       * Get fieldOne
       *
       * @return string
       */
      public function getFieldOne()
      {
          return $this-&gt;fieldOne;
      }
  
      /**
       * Set fieldTwo
       *
       * @param int $fieldTwo
       *
       * @return FooBar
       */
      public function setFieldTwo($fieldTwo)
      {
          $this-&gt;fieldTwo = $fieldTwo;
  
          return $this;
      }
  
      /**
       * Get fieldOne
       *
       * @return string
       */
      public function getFieldTwo()
      {
          return $this-&gt;fieldTwo;
      }
  }
  </code></pre>