Symfony2
当我在框架中提交表单时,我尝试使用正则表达式验证电子邮件地址。我在类中使用checkMX and checkHost
了属性。Entity
这完成了。但我无法验证它的正则表达式,即 {,$,#,!,^
......请帮助某人......这是我的代码片段......
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* product1
*/
class product1
{
/**
* @var int
*/
private $id;
/**
* @var string
* @Assert\Email(
*
* checkHost= true,
* checkMX = true,
* message="Invalid email host"
*
*
* )
* @Assert\Email(
* strict=false,
* message="invalid"
* )
*
*/
private $email;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set email
*
* @param string $email
*
* @return product1
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Get email
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
}