Symfony Validation Cheat Sheet

Validaciones en propiedades de una entidad

STRING:

http://symfony.com/doc/current/reference/constraints.html#string-constraints

/**
* @var string
*
* @ORM\Column(name="nombre", type="string", length=100)
* @Assert\NotBlank()
* @Assert\Length(min = 2, max = 100)
* @Assert\Type(type="string")
*/

INTEGER:

http://symfony.com/doc/current/reference/constraints/Type.html

/**
* @var int
*
* @ORM\Column(name="estado", type="integer")
* @Assert\Type(type="int")
* @Assert\Range(min = 120, max = 180)
*/

NUMERIC:

http://symfony.com/doc/current/reference/constraints/Type.html

/**
* @var string
*
* @Assert\Type(type="numeric")
*/

FLOAT:

http://symfony.com/doc/current/reference/constraints/Type.html

/**
* @var float
*
* @Assert\GreaterThan(value = 0)
* @Assert\Type(type="float")
*/

UNIQUE ENTITY:

use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;

/**
 * @ORM\Entity
 * @UniqueEntity("email")
 */

/**
 * @var string $email
 *
 * @ORM\Column(name="email", type="string", length=100, unique=true)
 * @Assert\Email()
 */