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]'); } }
public function visitDate($data, Property\DateType $property, $path) { $this->assertRequired($data, $property, $path); if ($data === null) { return true; } elseif ($data instanceof \DateTime) { return true; } elseif (is_string($data)) { $result = preg_match('/^' . DateTime\Date::getPattern() . '$/', $data); if ($result) { return true; } } throw new ValidationException($path . ' must be an valid full-date format (date-fullyear "-" date-month "-" date-mday) [RFC3339]'); }