我有一个密码提醒表单,其中一个字段=电子邮件。下面的代码。如果用户处于活动状态,如何添加其他验证?最佳做法是什么? EntityExist约束是我自己的代码。
namespace App\DTO\Admin\System;
use Symfony\Component\Validator\Constraints as Assert;
use App\Validator\Constraints as AppAssert;
class PasswordRemindData {
/**
* @Assert\NotBlank(message="validation.field.required")
* @Assert\Email(message="validation.email.invalid")
* @AppAssert\EntityExists(entityClass="App\Entity\Admin", field="email", message="validation.user.not_exists")
* @var string|null
*/
private $email;
public function __construct(?string $email = null) {
$this->email = $email;
}
/**
*
* @return string|null
*/
public function getEmail() {
return $this->email;
}
/**
*
* @param string|null $email
* @return PasswordRemindData
*/
public function setEmail($email) {
$this->email = $email;
return $this;
}
/**
*
* @param string $email
* @return PasswordRemindData
*/
public static function create(string $email) {
return new self($email);
}
}