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 not empty
13: *
14: * @author Twin Huang <twinhuang@qq.com>
15: */
16: class Present extends BaseValidator
17: {
18: protected $emptyMessage = '%name% must not be empty';
19:
20: protected $negativeMessage = '%name% must be empty';
21:
22: /**
23: * The invalid variables
24: *
25: * @var array
26: */
27: protected $invalid = array(null, '', false, array());
28:
29: /**
30: * {@inheritdoc}
31: */
32: protected function doValidate($input)
33: {
34: if (in_array($input, $this->invalid, true)) {
35: $this->addError('empty');
36: return false;
37: } else {
38: return true;
39: }
40: }
41: }
42: