mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
MINOR Code formatting in EmailField
This commit is contained in:
parent
1e61b76ca8
commit
8369cded32
@ -19,18 +19,17 @@ class EmailField extends TextField {
|
||||
* @param Validator $validator
|
||||
* @return String
|
||||
*/
|
||||
function validate($validator){
|
||||
function validate($validator) {
|
||||
$this->value = trim($this->value);
|
||||
|
||||
$pcrePattern = '^[a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$';
|
||||
|
||||
$pcrePattern = '^[a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$';
|
||||
|
||||
// PHP uses forward slash (/) to delimit start/end of pattern, so it must be escaped
|
||||
$pregSafePattern = str_replace('/', '\\/', $pcrePattern);
|
||||
|
||||
if($this->value && !preg_match('/' . $pregSafePattern . '/i', $this->value)){
|
||||
$validator->validationError(
|
||||
$this->name,
|
||||
$validator->validationError(
|
||||
$this->name,
|
||||
_t('EmailField.VALIDATION', "Please enter an email address."),
|
||||
"validation"
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user