Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
RegexValidator.php
Go to the documentation of this file.
1<?php
2
4
6
15 protected $ref;
16 protected $match;
17
18 public function __construct() {
19 $this->message = 'This value is not valid';
20 $this->match = true;
21 }
22
23 public function validate($value) {
24 parent::validate ( $value );
25 if ($this->notNull !== false) {
26 $value = ( string ) $value;
27 return ! ($this->match xor preg_match ( $this->ref, $value ));
28 }
29 return true;
30 }
31
37 public function getParameters(): array {
38 return [ 'value' ];
39 }
40
46 public function asUI(): array {
47 return \array_merge_recursive(parent::asUI () , ['rules'=>[['type' => 'regExp', 'prompt' => $this->_getMessage(), 'value' => $this->ref]]]);
48 }
49}
50
Validates a string with a regex Usage @validator("regex",pattern)
getParameters()
{{}\Ubiquity\contents\validation\validators\ValidatorInterfacegetParameters()}