1: <?php
2: /**
3: * Wei Framework
4: *
5: * @copyright Copyright (c) 2008-2015 Twin Huang
6: * @license http://opensource.org/licenses/mit-license.php MIT License
7: */
8:
9: namespace Wei\Validator;
10:
11: /**
12: * Check if the input is a positive integer (integer that greater than 0)
13: *
14: * @author Twin Huang <twinhuang@qq.com>
15: */
16: class PositiveInteger extends BaseValidator
17: {
18: protected $invalidMessage = '%name% must be positive integer';
19:
20: /**
21: * {@inheritdoc}
22: */
23: protected function doValidate($input)
24: {
25: if (false !== filter_var($input, FILTER_VALIDATE_INT) && $input > 0) {
26: return true;
27: } else {
28: $this->addError('invalid');
29: return false;
30: }
31: }
32: }