Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
AbstractDateTimeValidator.php
Go to the documentation of this file.
1<?php
2
4
7
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
Constraint Violation Generated During Validation with the ValidatorsManager.
getParameters()
{{}\Ubiquity\contents\validation\validators\ValidatorInterfacegetParameters()}