john smith
john smith

Reputation: 185

CakePHP Email Validation

Is it possible to perform specific email validation in 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.

Upvotes: 0

Views: 1773

Answers (1)

Farkie
Farkie

Reputation: 3337

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'
    )
);

Upvotes: 3

Related Questions