12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- /**
- *
- * Cube Framework $Id$ IhS0obfuyVroCfh4+I48qXA/qqiB9Uq2WgEUR41GqlE=
- *
- * @link http://codecu.be/framework
- * @copyright Copyright (c) 2017 CodeCube SRL
- * @license http://codecu.be/framework/license Commercial License
- *
- * @version 1.10 [rev.1.10.01]
- */
- /**
- * digits only validator class
- */
- namespace Cube\Validate;
- class Digits extends AbstractValidate
- {
-
- protected $_message = "'%s' can only contain digits.";
- /**
- *
- * checks if the variable contains digits only
- *
- * @return bool return true if the validation is successful
- */
- public function isValid()
- {
- $value = $this->getValue();
- if (empty($value)) {
- return true;
- }
- if (!preg_match('#^-?[0-9]+$#', $value)) {
- return false;
- }
- return true;
- }
- }
|