1: <?php
2: 3: 4: 5: 6: 7:
8:
9: namespace Wei\Validator;
10:
11: 12: 13: 14: 15:
16: class Exists extends BaseValidator
17: {
18: protected $notFoundMessage = '%name% must be an existing file or directory';
19:
20: protected $negativeMessage = '%name% must be a non-existing file or directory';
21:
22: 23: 24:
25: protected function doValidate($input)
26: {
27: if (!$this->isString($input)) {
28: $this->addError('notString');
29: return false;
30: }
31:
32: $file = stream_resolve_include_path($input);
33: if (!$file) {
34: $this->addError('notFound');
35: return false;
36: }
37:
38: return true;
39: }
40: }
41: