Datepicker’s `minDate` attribute is not validating keyboard input.

Bug description:

Datepicker’s minDate attribute is not validating keyboard input.
Say, I set minDate to 2017-7-20.

  • Through calendar control, I am not able to set any date below 2017-7-20, which is good as intended.
  • But I can type in the date 2017-7-10 through Keyboard. No validation errors happening. The date is being accepted

Link to minimally-working plunker that reproduces the issue:

http://plnkr.co/edit/cGmJA2A0pQh6eukD1kb3?p=preview

Version of Angular, ng-bootstrap, and Bootstrap:

Angular: 4.0.3

ng-bootstrap: 1.0.0-alpha.27

Bootstrap: 4.0.0-alpha.6

1 possible answer(s) on “Datepicker’s `minDate` attribute is not validating keyboard input.

  1. How do you know it’s marked as Invalid?

    Just inspect the DOM and see that Angular validation CSS classes (ex.: ng-invalid) are added properly. This proves that the control is marked as invalid.

    When I enter the date below minDate via Keyboard, on lost focus, it should throw some error in (ngModelChange) or something and reset to previous valid date or reset to null.

    The Angular way of “throw some error” is to mark control as invalid. We want to follow what is happening in Angular forms and not to invent datepicker-specific way of handing invalid input.

    So the developers can catch the error and handle properly.

    Once again, you should use control’s validity state to provide adequate feedback to the users.

    I’m going to close this one as it works as intended.