Ubiquity
2.5.2
php rapid development framework
Loading...
Searching...
No Matches
AbstractDateTimeValidator.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Ubiquity\contents\validation\validators\dates
;
4
5
use
Ubiquity\contents\validation\validators\ConstraintViolation
;
6
use
Ubiquity\contents\validation\validators\ValidatorHasNotNull
;
7
8
abstract
class
AbstractDateTimeValidator
extends
ValidatorHasNotNull
{
9
protected
$ref
;
10
protected
$strict
=
true
;
11
protected
$warnings
= [ ];
12
13
public
function
validate
(
$value
) {
14
parent::validate (
$value
);
15
if
($this->notNull !==
false
) {
16
$value
= ( string )
$value
;
17
\DateTime::createFromFormat ( $this->ref,
$value
);
18
$errors = \DateTime::getLastErrors ();
19
foreach
( $errors [
'warnings'
] as $warning ) {
20
$this->warnings [] =
new
ConstraintViolation
( $warning,
$value
, $this->member, get_class ( $this ),
'warning'
);
21
}
22
return
$errors [
'error_count'
] <= 0 && (! $this->strict || $errors [
'warning_count'
] <= 0);
23
}
24
return
true
;
25
}
26
32
public
function
getParameters
(): array {
33
return [
"ref"
,
"value"
];
34
}
35
40
public
function
getWarnings
() {
41
return
$this->warnings;
42
}
43
44
public
function
hasWarnings
() {
45
return \count ( $this->warnings ) > 0;
46
}
47
}
48
Ubiquity\contents\validation\validators\ConstraintViolation
Constraint Violation Generated During Validation with the ValidatorsManager.
Definition
ConstraintViolation.php:18
Ubiquity\contents\validation\validators\ValidatorHasNotNull
Definition
ValidatorHasNotNull.php:8
Ubiquity\contents\validation\validators\Validator\$value
$value
Definition
Validator.php:15
Ubiquity\contents\validation\validators\dates\AbstractDateTimeValidator
Definition
AbstractDateTimeValidator.php:8
Ubiquity\contents\validation\validators\dates\AbstractDateTimeValidator\getParameters
getParameters()
{{}\Ubiquity\contents\validation\validators\ValidatorInterfacegetParameters()}
Definition
AbstractDateTimeValidator.php:32
Ubiquity\contents\validation\validators\dates\AbstractDateTimeValidator\$warnings
$warnings
Definition
AbstractDateTimeValidator.php:11
Ubiquity\contents\validation\validators\dates\AbstractDateTimeValidator\validate
validate($value)
Definition
AbstractDateTimeValidator.php:13
Ubiquity\contents\validation\validators\dates\AbstractDateTimeValidator\$strict
$strict
Definition
AbstractDateTimeValidator.php:10
Ubiquity\contents\validation\validators\dates\AbstractDateTimeValidator\getWarnings
getWarnings()
Definition
AbstractDateTimeValidator.php:40
Ubiquity\contents\validation\validators\dates\AbstractDateTimeValidator\hasWarnings
hasWarnings()
Definition
AbstractDateTimeValidator.php:44
Ubiquity\contents\validation\validators\dates\AbstractDateTimeValidator\$ref
$ref
Definition
AbstractDateTimeValidator.php:9
Ubiquity\contents\validation\validators\dates
Definition
AbstractDateTimeValidator.php:3
C:
Users
myadd
Documents
GitHub
ubiquity-doc-api
vendor
phpmv
ubiquity
src
Ubiquity
contents
validation
validators
dates
AbstractDateTimeValidator.php
Generated on Sun Dec 10 2023 15:04:15 for
Ubiquity
by
doxygen
1.9.8