public static function onAddCustomRegexp($rgxp, $value, $widget)
    {
        if ('MetaModelsFilterRangeDateRgXp' !== $rgxp) {
            return;
        }
        $format = $widget->dateformat;

        if (!\preg_match('~^'. Date::getRegexp($format) .'$~i', $value)) {
            $widget->addError(\sprintf($GLOBALS['TL_LANG']['ERR']['date'], Date::getInputFormat($format)));
        } else {
            // Validate the date (see https://github.com/contao/core/issues/5086)
            try {
                new Date($value, $format);
            } catch (\OutOfBoundsException $e) {
                $widget->addError(\sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $value));
            }
        }
    }