Ubiquity
2.5.2
php rapid development framework
Loading...
Searching...
No Matches
RegexValidator.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Ubiquity\contents\validation\validators\strings
;
4
5
use
Ubiquity\contents\validation\validators\ValidatorHasNotNull
;
6
14
class
RegexValidator
extends
ValidatorHasNotNull
{
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
Ubiquity\contents\validation\validators\ValidatorHasNotNull
Definition
ValidatorHasNotNull.php:8
Ubiquity\contents\validation\validators\Validator\$value
$value
Definition
Validator.php:15
Ubiquity\contents\validation\validators\strings\RegexValidator
Validates a string with a regex Usage @validator("regex",pattern)
Definition
RegexValidator.php:14
Ubiquity\contents\validation\validators\strings\RegexValidator\getParameters
getParameters()
{{}\Ubiquity\contents\validation\validators\ValidatorInterfacegetParameters()}
Definition
RegexValidator.php:37
Ubiquity\contents\validation\validators\strings\RegexValidator\__construct
__construct()
Definition
RegexValidator.php:18
Ubiquity\contents\validation\validators\strings\RegexValidator\validate
validate($value)
Definition
RegexValidator.php:23
Ubiquity\contents\validation\validators\strings\RegexValidator\$match
$match
Definition
RegexValidator.php:16
Ubiquity\contents\validation\validators\strings\RegexValidator\asUI
asUI()
{}
Definition
RegexValidator.php:46
Ubiquity\contents\validation\validators\strings\RegexValidator\$ref
$ref
Definition
RegexValidator.php:15
Ubiquity\contents\validation\validators\strings
Definition
EmailValidator.php:3
C:
Users
myadd
Documents
GitHub
ubiquity-doc-api
vendor
phpmv
ubiquity
src
Ubiquity
contents
validation
validators
strings
RegexValidator.php
Generated on Sun Dec 10 2023 15:04:16 for
Ubiquity
by
doxygen
1.9.8