Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
TypeValidator.php
Go to the documentation of this file.
1<?php
2
4
6
8 protected $ref;
9
10 public function __construct() {
11 $this->message = "The value {value} is not a valid {ref}.";
12 }
13
14 public function validate($value) {
15 parent::validate ( $value );
16 if ($this->notNull !== false) {
17 $type = strtolower ( $this->ref );
18 $type = 'boolean' == $type ? 'bool' : $type;
19 $isFunction = 'is_' . $type;
20 $ctypeFunction = 'ctype_' . $type;
21 if (\function_exists ( $isFunction ) && $isFunction ( $value )) {
22 return true;
23 } elseif (\function_exists ( $ctypeFunction ) && $ctypeFunction ( $value )) {
24 return true;
25 } elseif ($value instanceof $this->ref) {
26 return true;
27 }
28 return false;
29 }
30 return true;
31 }
32
38 public function getParameters(): array {
39 return [ "ref","value" ];
40 }
41}
42
getParameters()
{{}\Ubiquity\contents\validation\validators\ValidatorInterfacegetParameters()}