File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -403,8 +403,11 @@ public static function datetime(
403403 if ($ data === null ) {
404404 return false ;
405405 }
406- $ data = \DateTime::createFromFormat ($ format , $ data );
407- if ($ data === false ) {
406+ $ datetime = \DateTime::createFromFormat ($ format , $ data );
407+ if ($ datetime === false ) {
408+ return false ;
409+ }
410+ if ($ datetime ->format ($ format ) !== $ data ) {
408411 return false ;
409412 }
410413 $ lastErrors = \DateTime::getLastErrors ();
Original file line number Diff line number Diff line change @@ -176,6 +176,9 @@ public function testDatetime() : void
176176 self ::assertTrue (Validator::datetime ('year ' , $ this ->array , 'Y ' ));
177177 self ::assertFalse (Validator::datetime ('alpha ' , $ this ->array ));
178178 self ::assertFalse (Validator::datetime ('unknown ' , $ this ->array ));
179+ self ::assertFalse (Validator::datetime ('foo ' , [
180+ 'foo ' => '023-01-10 ' ,
181+ ], 'Y-m-d ' ));
179182 }
180183
181184 public function testEquals () : void
You can’t perform that action at this time.
0 commit comments