Example #1
0
 public function testVisitDateDateTime()
 {
     $visitor = new ValidationVisitor();
     $property = Property::getDate('test');
     $this->assertTrue($visitor->visitDate(new \DateTime(), $property, ''));
 }
Example #2
0
 public function visitDate($data, Property\DateType $property, $path)
 {
     if ($this->validate) {
         parent::visitDate($data, $property, $path);
     } else {
         $this->assertRequired($data, $property, $path);
     }
     if ($data instanceof \DateTime) {
         return $this->createSimpleProperty(Date::fromDateTime($data), $property);
     }
     try {
         return $this->createSimpleProperty(new Date($data), $property);
     } catch (\Exception $e) {
         throw new ValidationException($path . ' must be an valid full-date format (date-fullyear "-" date-month "-" date-mday) [RFC3339]');
     }
 }