angular-ui/bootstrap — pull request #1845 by rickirunge (2014-02-23 17:20:02+00:00)
Title: Bugfix: Datepicker doesn't mark input field invalid if the date is invalid

I wanted to use the date picker, with the danish date format "dd/MM/yyyy", and found several issues (#956, #1107, #1430) and also a TODO in the code, all refering to that this was not yet implemented for manual typing in the input field.

One solution I found described in the issues (#956) was to use: https://github.com/dnasir/angular-dateParser, which works perfect - except an error in angular UI datepicker became visible.

If your from the JS set the value of date-field to a date that is invalid (for instance new Date(undefined) or new Date("pizza"), which both return a date object, in the state "Invalid Date"), the field is not marked "invalid".

Fix is simple, right now the code just checks if the value is a date, and then marks is valid. But we just need to also check that the date is actual valid ( isNan(date) return true the date is invalid)