| Conditions | 3 |
| Paths | 2 |
| Total Lines | 20 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 38 | public function validate($validator) { |
||
| 39 | $this->value = trim($this->value); |
||
| 40 | |||
| 41 | $pattern = '^[a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$'; |
||
| 42 | |||
| 43 | // Escape delimiter characters. |
||
| 44 | $safePattern = str_replace('/', '\\/', $pattern); |
||
| 45 | |||
| 46 | if($this->value && !preg_match('/' . $safePattern . '/i', $this->value)) { |
||
| 47 | $validator->validationError( |
||
| 48 | $this->name, |
||
| 49 | _t('EmailField.VALIDATION', 'Please enter an email address'), |
||
| 50 | 'validation' |
||
| 51 | ); |
||
| 52 | |||
| 53 | return false; |
||
| 54 | } |
||
| 55 | |||
| 56 | return true; |
||
| 57 | } |
||
| 58 | |||
| 65 |