Ubiquity
2.5.2
php rapid development framework
Loading...
Searching...
No Matches
Validator.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Ubiquity\contents\validation\validators
;
4
11
abstract
class
Validator
implements
ValidatorInterface
{
12
protected
$modifiedMessage
;
13
protected
$message
;
14
protected
$member
;
15
protected
$value
;
16
protected
$severity
;
17
23
public
function
validate_
(
$value
) {
24
$this->value =
$value
;
25
if
(! $this->
validate
(
$value
)) {
26
return
new
ConstraintViolation
( $this->
_getMessage
(),
$value
, $this->member, \get_class ( $this ), $this->severity );
27
}
28
return
true
;
29
}
30
31
public
function
setValidationParameters
(
$member
, $params,
$severity
=
'warning'
,
$message
=
null
) {
32
$this->
setParams
( $params );
33
$this->member =
$member
;
34
$this->modifiedMessage =
$message
;
35
$this->severity =
$severity
;
36
}
37
38
protected
function
setParams
(array $params) {
39
foreach
( $params as
$member
=>
$value
) {
40
$this->
$member
=
$value
;
41
}
42
}
43
48
public
function
getMember
() {
49
return
$this->member
;
50
}
51
56
public
function
setMember
(
$member
) {
57
$this->member =
$member
;
58
}
59
65
public
function
getParameters
(): array {
66
return [ ];
67
}
68
73
protected
function
mergeMessages
() {
74
if
(! isset ( $this->modifiedMessage )) {
75
return
$this->message;
76
}
else
{
77
return
$this->modifiedMessage;
78
}
79
}
80
81
protected
function
_getMessage
() {
82
$parameters = $this->getParameters ();
83
$message = $this->mergeMessages ();
84
foreach
( $parameters as $param ) {
85
$message = \str_replace (
"{"
. $param .
"}"
, $this->$param??
''
, $message );
86
}
87
return
$message;
88
}
89
90
public
function
asUI
(): array {
91
return [ ];
92
}
93
}
94
Ubiquity\contents\validation\validators\ConstraintViolation
Constraint Violation Generated During Validation with the ValidatorsManager.
Definition
ConstraintViolation.php:18
Ubiquity\contents\validation\validators\Validator
Abstract class for validators.
Definition
Validator.php:11
Ubiquity\contents\validation\validators\Validator\getParameters
getParameters()
{}
Definition
Validator.php:65
Ubiquity\contents\validation\validators\Validator\setMember
setMember($member)
Definition
Validator.php:56
Ubiquity\contents\validation\validators\Validator\$value
$value
Definition
Validator.php:15
Ubiquity\contents\validation\validators\Validator\setParams
setParams(array $params)
Definition
Validator.php:38
Ubiquity\contents\validation\validators\Validator\validate_
validate_($value)
Definition
Validator.php:23
Ubiquity\contents\validation\validators\Validator\mergeMessages
mergeMessages()
Definition
Validator.php:73
Ubiquity\contents\validation\validators\Validator\$member
$member
Definition
Validator.php:14
Ubiquity\contents\validation\validators\Validator\_getMessage
_getMessage()
Definition
Validator.php:81
Ubiquity\contents\validation\validators\Validator\getMember
getMember()
Definition
Validator.php:48
Ubiquity\contents\validation\validators\Validator\$severity
$severity
Definition
Validator.php:16
Ubiquity\contents\validation\validators\Validator\$message
$message
Definition
Validator.php:13
Ubiquity\contents\validation\validators\Validator\asUI
asUI()
Definition
Validator.php:90
Ubiquity\contents\validation\validators\Validator\setValidationParameters
setValidationParameters($member, $params, $severity='warning', $message=null)
Definition
Validator.php:31
Ubiquity\contents\validation\validators\Validator\$modifiedMessage
$modifiedMessage
Definition
Validator.php:12
Ubiquity\contents\validation\validators\ValidatorInterface
Definition
ValidatorInterface.php:5
Ubiquity\contents\validation\validators\ValidatorInterface\validate
validate($value)
Ubiquity\contents\validation\validators
Validators definition.
C:
Users
myadd
Documents
GitHub
ubiquity-doc-api
vendor
phpmv
ubiquity
src
Ubiquity
contents
validation
validators
Validator.php
Generated on Sun Dec 10 2023 15:04:16 for
Ubiquity
by
doxygen
1.9.8