[BUGFIX] Form localization depending on old class names
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Classes / Validation / IntegerValidator.php
1 <?php
2 namespace TYPO3\CMS\Form\Validation;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Integer rule
19 *
20 * @author Patrick Broens <patrick@patrickbroens.nl>
21 */
22 class IntegerValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator {
23
24 /**
25 * Constant for localisation
26 *
27 * @var string
28 */
29 const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_integer';
30
31 /**
32 * Returns TRUE if submitted value validates according to rule
33 *
34 * @return bool
35 * @see \TYPO3\CMS\Form\Validation\ValidatorInterface::isValid()
36 */
37 public function isValid() {
38 if ($this->requestHandler->has($this->fieldName)) {
39 $value = $this->requestHandler->getByMethod($this->fieldName);
40 $locale = localeconv();
41 $valueFiltered = str_replace(
42 array(
43 $locale['thousands_sep'],
44 $locale['mon_thousands_sep'],
45 $locale['decimal_point'],
46 $locale['mon_decimal_point']
47 ),
48 array(
49 '',
50 '',
51 '.',
52 '.'
53 ),
54 $value
55 );
56 if (strval((int)$valueFiltered) != $valueFiltered) {
57 return FALSE;
58 }
59 }
60 return TRUE;
61 }
62
63 }