1: <?php
2:
3: /**
4: * Pry Framework
5: *
6: * LICENSE
7: *
8: * This source file is subject to the new BSD license that is bundled
9: * with this package in the file LICENSE.txt.
10: *
11: */
12:
13: namespace Pry\Validate\Validator;
14:
15: use Pry\Validate\ValidateAbstract;
16:
17: /**
18: * Validateur de données numériques
19: * @category Pry
20: * @package Validate
21: * @subpackage Validate_Validator
22: * @version 1.0.0
23: * @author Olivier ROGER <oroger.fr>
24: *
25: */
26: class Digit extends ValidateAbstract
27: {
28:
29: /**
30: * Constructeur
31: *
32: */
33: public function __construct()
34: {
35: $this->errorMsg = "doit être composé de chiffre uniquement";
36: }
37:
38: /**
39: * Validation
40: *
41: * @param string $string Element à valider
42: * @return boolean
43: */
44: public function isValid($string)
45: {
46: $string = $this->cleanString((string) $string);
47: $pattern = '`^([0-9]+)$`';
48: if (preg_match($pattern, $string))
49: return true;
50: return false;
51: }
52:
53: }
54:
55: ?>