Date rules and Kartik DatePicker Widget

Since Yii2 2.04 it is possible to write:

    public function rules()


        return [

		['birthdate', 'date', 'format' => 'd-m-Y',

                 'max' => '31-12-2010',

                 'min' => '01-01-1900',

                 'tooBig' => 'Too young.',

                 'tooSmall' => 'Too old.'],

However, if I use the Kartik datepicker, these rules are not checked.

If I enter for example "13-11-20156" -> an 6 too many, with the above rules, I get the error:

Invalid Parameter – yii\base\InvalidParamException

‘13-11-20158’ is not a valid date time value: DateTime::__construct(): Failed to parse time string (13-11-20156) at position 10 (8): Unexpected character


A form without the Kartik datepicker works fine and gives the correct errormessages.

The question is of course why?

First of all you should use correct ICU formatting or add ‘php:’ prefix if you want the php date format (like now).

What is the error message for form without datepicker?

In this situation Yii2 works as expected. The correct error messages are shown.

Moreover, the error only arises in debug mode, not in production mode. In debug mode it crashes. In production mode the data field is cleared and the message «date should not be empty» is shown.