Created
November 28, 2011 01:05
-
-
Save msng/1398645 to your computer and use it in GitHub Desktop.
Another CakePHP validation rule for email, accepting irregular addresses once allowed by docomo and au
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//For PHP 5.3.x or later | |
public function emailExtended($data, $deep = false) { | |
$pattern = '/.+@(docomo|ezweb)\.ne\.jp$/i'; | |
$check = preg_replace_callback($pattern, function($matches) { | |
$patterns = array('/\.{2,}/', '/\.@/'); | |
$replacements = array('.', '@'); | |
return preg_replace($patterns, $replacements, $matches[0]); | |
}, array_shift($data)); | |
return Validation::email($check, $deep); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//For PHP 5.2.x or earlier | |
public function emailExtended($data, $deep = false) { | |
$pattern = '/.+@(docomo|ezweb)\.ne\.jp$/i'; | |
$check = preg_replace_callback($pattern, create_function('$matches', ' | |
$patterns = array("/\.{2,}/", "/\.@/"); | |
$replacements = array(".", "@"); | |
return preg_replace($patterns, $replacements, $matches[0]); | |
'), array_shift($data)); | |
return Validation::email($check, $deep); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment