Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I validate an email address in CakePHP 1.3?

I wanted to integrate a verified email address functionality in CakePHP 1.3.

I have used valid email address regular expressions but I have never ever verified an email address' domain (a valid domain name means existing domain name).

I know how this is done in plain PHP but I want to use CakePHP's functionality to achieve this.

like image 504
Ayesha Avatar asked Nov 26 '25 14:11

Ayesha


2 Answers

There is already built-in functionality you can use.

Read the documentation:

  • Cake 2.0
  • Cake 1.3

Note the boolean $deep = false param which you can use to actually check for the domains existence.

like image 152
mark Avatar answered Nov 28 '25 02:11

mark


assign this into your model

public $validate = array(       
        'email' => array(
            'email' => array(
                'rule' => array('email',true),
                'message' => 'Your custom message here',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
);
like image 41
Fury Avatar answered Nov 28 '25 02:11

Fury



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!