Exemplo n.º 1
0
 public function testVisitDateTimeDateTime()
 {
     $visitor = new ValidationVisitor();
     $property = Property::getDateTime('test');
     $this->assertTrue($visitor->visitDateTime(new \DateTime(), $property, ''));
 }
Exemplo n.º 2
0
 public function visitDateTime($data, Property\DateTimeType $property, $path)
 {
     if ($this->validate) {
         parent::visitDateTime($data, $property, $path);
     } else {
         $this->assertRequired($data, $property, $path);
     }
     if ($data instanceof \DateTime) {
         return $this->createSimpleProperty($data, $property);
     }
     try {
         return $this->createSimpleProperty(new DateTime($data), $property);
     } catch (\Exception $e) {
         throw new ValidationException($path . ' must be an valid date-time format (full-date "T" full-time) [RFC3339]');
     }
 }