src/EventListener/FilterRangeDateRegexpListener.php
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));
            }
        }
    }
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));
            }
        }
    }
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 ) ) ; } } }
Process a custom date regexp on a widget.

@param string $rgxp   The rgxp being evaluated.

@param string $value  The value to check.

@param Widget $widget The widget to process.

@return void

@SuppressWarnings(PHPMD.Superglobals)
@SuppressWarnings(PHPMD.CamelCaseVariableName)
Process a custom date regexp on a widget .