protected function isValid($value)
    {
        if ($value instanceof \DateTimeInterface) {
            return;
        }
        if (!isset($this->options['locale'])) {
            $locale = $this->localizationService->getConfiguration()->getDefaultLocale();
        } elseif (is_string($this->options['locale'])) {
            $locale = new I18n\Locale($this->options['locale']);
        } elseif ($this->options['locale'] instanceof I18n\Locale) {
            $locale = $this->options['locale'];
        } else {
            $this->addError('The "locale" option can be only set to string identifier, or Locale object.', 1281454676);
            return;
        }

        $strictMode = $this->options['strictMode'];

        $formatLength = $this->options['formatLength'];
        DatesReader::validateFormatLength($formatLength);

        $formatType = $this->options['formatType'];
        DatesReader::validateFormatType($formatType);

        if ($formatType === DatesReader::FORMAT_TYPE_TIME) {
            if ($this->datetimeParser->parseTime($value, $locale, $formatLength, $strictMode) === false) {
                $this->addError('A valid time is expected.', 1281454830);
            }
        } elseif ($formatType === DatesReader::FORMAT_TYPE_DATETIME) {
            if ($this->datetimeParser->parseDateAndTime($value, $locale, $formatLength, $strictMode) === false) {
                $this->addError('A valid date and time is expected.', 1281454831);
            }
        } else {
            if ($this->datetimeParser->parseDate($value, $locale, $formatLength, $strictMode) === false) {
                $this->addError('A valid date is expected.', 1281454832);
            }
        }
    }
protected function isValid($value)
    {
        if ($value instanceof \DateTimeInterface) {
            return;
        }
        if (!isset($this->options['locale'])) {
            $locale = $this->localizationService->getConfiguration()->getDefaultLocale();
        } elseif (is_string($this->options['locale'])) {
            $locale = new I18n\Locale($this->options['locale']);
        } elseif ($this->options['locale'] instanceof I18n\Locale) {
            $locale = $this->options['locale'];
        } else {
            $this->addError('The "locale" option can be only set to string identifier, or Locale object.', 1281454676);
            return;
        }

        $strictMode = $this->options['strictMode'];

        $formatLength = $this->options['formatLength'];
        DatesReader::validateFormatLength($formatLength);

        $formatType = $this->options['formatType'];
        DatesReader::validateFormatType($formatType);

        if ($formatType === DatesReader::FORMAT_TYPE_TIME) {
            if ($this->datetimeParser->parseTime($value, $locale, $formatLength, $strictMode) === false) {
                $this->addError('A valid time is expected.', 1281454830);
            }
        } elseif ($formatType === DatesReader::FORMAT_TYPE_DATETIME) {
            if ($this->datetimeParser->parseDateAndTime($value, $locale, $formatLength, $strictMode) === false) {
                $this->addError('A valid date and time is expected.', 1281454831);
            }
        } else {
            if ($this->datetimeParser->parseDate($value, $locale, $formatLength, $strictMode) === false) {
                $this->addError('A valid date is expected.', 1281454832);
            }
        }
    }
protected function isValid ( $ value ) { if ( $ value instanceof \ DateTimeInterface ) { return ; } if ( ! isset ( $ this -> options [ 'locale' ] ) ) { $ locale = $ this -> localizationService -> getConfiguration ( ) -> getDefaultLocale ( ) ; } elseif ( is_string ( $ this -> options [ 'locale' ] ) ) { $ locale = new I18n \ Locale ( $ this -> options [ 'locale' ] ) ; } elseif ( $ this -> options [ 'locale' ] instanceof I18n \ Locale ) { $ locale = $ this -> options [ 'locale' ] ; } else { $ this -> addError ( 'The "locale" option can be only set to string identifier, or Locale object.' , 1281454676 ) ; return ; } $ strictMode = $ this -> options [ 'strictMode' ] ; $ formatLength = $ this -> options [ 'formatLength' ] ; DatesReader :: validateFormatLength ( $ formatLength ) ; $ formatType = $ this -> options [ 'formatType' ] ; DatesReader :: validateFormatType ( $ formatType ) ; if ( $ formatType === DatesReader :: FORMAT_TYPE_TIME ) { if ( $ this -> datetimeParser -> parseTime ( $ value , $ locale , $ formatLength , $ strictMode ) === false ) { $ this -> addError ( 'A valid time is expected.' , 1281454830 ) ; } } elseif ( $ formatType === DatesReader :: FORMAT_TYPE_DATETIME ) { if ( $ this -> datetimeParser -> parseDateAndTime ( $ value , $ locale , $ formatLength , $ strictMode ) === false ) { $ this -> addError ( 'A valid date and time is expected.' , 1281454831 ) ; } } else { if ( $ this -> datetimeParser -> parseDate ( $ value , $ locale , $ formatLength , $ strictMode ) === false ) { $ this -> addError ( 'A valid date is expected.' , 1281454832 ) ; } } }
Checks if the given value is a valid DateTime object.

@param mixed $value The value that should be validated
@return void
@api
Checks if the given value is a valid DateTime object .