[TASK] Replace FormEngine update request invocation
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Validation / Validator / EmailAddressValidator.php
1 <?php
2
3 /*
4 * This file is part of the TYPO3 CMS project.
5 *
6 * It is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License, either version 2
8 * of the License, or any later version.
9 *
10 * For the full copyright and license information, please read the
11 * LICENSE.txt file that was distributed with this source code.
12 *
13 * The TYPO3 project - inspiring people to share!
14 */
15
16 namespace TYPO3\CMS\Extbase\Validation\Validator;
17
18 use TYPO3\CMS\Core\Utility\GeneralUtility;
19
20 /**
21 * Validator for email addresses
22 */
23 class EmailAddressValidator extends AbstractValidator
24 {
25 /**
26 * Checks if the given value is a valid email address.
27 *
28 * @param mixed $value The value that should be validated
29 */
30 public function isValid($value)
31 {
32 if (!is_string($value) || !$this->validEmail($value)) {
33 $this->addError(
34 $this->translateErrorMessage(
35 'validator.emailaddress.notvalid',
36 'extbase'
37 ),
38 1221559976
39 );
40 }
41 }
42
43 /**
44 * Checking syntax of input email address
45 *
46 * @param string $emailAddress Input string to evaluate
47 * @return bool Returns TRUE if the $email address (input string) is valid
48 */
49 protected function validEmail($emailAddress)
50 {
51 return GeneralUtility::validEmail($emailAddress);
52 }
53 }