简体   繁体   English

CakePHP电子邮件验证

[英]CakePHP Email Validation

Is it possible to perform specific email validation in cakephp? 是否可以在cakephp中执行特定的电子邮件验证? In my model file, I have 在我的模型文件中

public $validate = array(
    'email' => array( 
    'required' => 'true',
    'rule' => array('email', true),
    'message'=> 'Please supply a valid email address.')
);

But I want to be able to enforce the constraint that the email address will end in something specific, for example: 但我希望能够强制执行以下限制:电子邮件地址以特定的结尾,例如:

@example.com

Any help would be appreciated, thanks. 任何帮助,将不胜感激,谢谢。

You could add a custom one if you are enforcing the constraint on a domain.. 如果要对域强制执行约束,则可以添加一个自定义项。

 public $validate = array(
    'login' => array(
        'rule'    => '/^.+@domain\.com$/i',
        'message' => 'This email address must be @domain.com'
    )
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM