fix calendar css, take 2. (#213)
[openemr.git] / interface / modules / zend_modules / library / Zend / Validator / Digits.php
blob94210c917d9c61fc45ba7e5fc1c4e44dd49d5f03
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Validator;
12 use Zend\Filter\Digits as DigitsFilter;
14 class Digits extends AbstractValidator
16 const NOT_DIGITS = 'notDigits';
17 const STRING_EMPTY = 'digitsStringEmpty';
18 const INVALID = 'digitsInvalid';
20 /**
21 * Digits filter used for validation
23 * @var \Zend\Filter\Digits
25 protected static $filter = null;
27 /**
28 * Validation failure message template definitions
30 * @var array
32 protected $messageTemplates = array(
33 self::NOT_DIGITS => "The input must contain only digits",
34 self::STRING_EMPTY => "The input is an empty string",
35 self::INVALID => "Invalid type given. String, integer or float expected",
38 /**
39 * Returns true if and only if $value only contains digit characters
41 * @param string $value
42 * @return bool
44 public function isValid($value)
46 if (!is_string($value) && !is_int($value) && !is_float($value)) {
47 $this->error(self::INVALID);
48 return false;
51 $this->setValue((string) $value);
53 if ('' === $this->getValue()) {
54 $this->error(self::STRING_EMPTY);
55 return false;
58 if (null === static::$filter) {
59 static::$filter = new DigitsFilter();
62 if ($this->getValue() !== static::$filter->filter($this->getValue())) {
63 $this->error(self::NOT_DIGITS);
64 return false;
67 return true;