protected function validateDate($value, string $parameter, array $args = [], array $rules = null, array $context = null): ?string
    {
        $format = $args[0] ?? null;

        if ($format === '') {
            throw new ValidatorConfigException("Invalid format specified in 'date' validator for parameter {$parameter}");
        }

        //$value = $this->getValue($parameter);

        if ($value === null) {
            return null;
        }

        if (!is_scalar($value)) {
            return Message::getMessage(Message::PRIMITIVE, [
                'param' => $parameter
            ]);
        }

        $value = trim((string)$value);

        if ($value === '') {
            return null;
        }

        if ($format === null) {
            // no format, use simple strtotime()
            if (strtotime($value) === false) {
                return Message::getMessage(Message::DATE, [
                    'param' => $parameter,
                    'value' => $value
                ]);
            }
        } else {
            $dateTime = \DateTime::createFromFormat($format, $value);
            if ($dateTime === false || $dateTime->format($format) !== $value) {
                return Message::getMessage(Message::DATE, [
                    'param' => $parameter,
                    'value' => $value
                ]);
            }
        }

        return null;
    }