语义错误;注释" @Symfony \ Component \ Validator \ Constraints \ MinLength"

时间:2014-07-14 13:36:52

标签: symfony validation

使用Validator我有这个错误

  

[语义错误]注释" @Symfony \ Component \ Validator \ Constraints \ MinLength"属性My \ testBundle \ Entity \ Desk :: $ title不存在,或者无法自动加载。

namespace My\testBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/**
* Desk
*
* @ORM\Table(name="desk")
* @ORM\Entity(repositoryClass="My\testBundle\Repository\DeskRepository")
*/
class Desk
{
/**
 * @ORM\OneToMany(targetEntity="DeskComment", mappedBy="desk", cascade={"remove", "persist"})
 */
protected $comments;
/**
 * @var integer
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 */
private $id;

/**
 * @var string
 * 
 *
 * @ORM\Column(name="title", type="string", length=255)
 * @Assert\NotBlank()
 * @Assert\MinLength(
 *     limit=3,
 *     message="Your name must have at least {{ limit }} characters."
 * )
 */
private $title;

/**
 * @var string
 *
 * @ORM\Column(name="symmary", type="text")
 */
private $symmary;

/**
 * @var string
 *
 * @ORM\Column(name="description", type="text")
 */
private $description;

/**
 * @var string
 *
 * @ORM\Column(name="note", type="decimal", nullable=true)
 */
private $note;

问题是@Assert\MinLength

任何帮助?

1 个答案:

答案 0 :(得分:1)

使用Length代替min。

来自docs

The MinLength constraint is deprecated since version 2.1 and will be removed
in Symfony 2.3. Use Length with the min option instead.