This repository was archived by the owner on Sep 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
src/components/datepicker Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 367
367
* @param {Date= } opt_date Date to check. If not given, defaults to the datepicker's model value.
368
368
*/
369
369
DatePickerCtrl . prototype . updateErrorState = function ( opt_date ) {
370
- // Force all dates to midnight in order to ignore the time portion.
371
- var date = this . dateUtil . createDateAtMidnight ( opt_date || this . date ) ;
370
+ var date = opt_date || this . date ;
372
371
373
372
// Clear any existing errors to get rid of anything that's no longer relevant.
374
373
this . clearErrorState ( ) ;
375
374
376
375
if ( this . dateUtil . isValidDate ( date ) ) {
376
+ // Force all dates to midnight in order to ignore the time portion.
377
+ date = this . dateUtil . createDateAtMidnight ( date ) ;
378
+
377
379
if ( this . dateUtil . isValidDate ( this . minDate ) ) {
378
380
var minDate = this . dateUtil . createDateAtMidnight ( this . minDate ) ;
379
381
this . ngModelCtrl . $setValidity ( 'mindate' , date >= minDate ) ;
Original file line number Diff line number Diff line change @@ -189,6 +189,24 @@ describe('md-date-picker', function() {
189
189
expect ( controller . ngModelCtrl . $error [ 'mindate' ] ) . toBeFalsy ( ) ;
190
190
} ) ;
191
191
192
+ it ( 'should not enforce `required` when a min-date is set' , function ( ) {
193
+ pageScope . isRequired = false ;
194
+ pageScope . minDate = new Date ( 2015 , JAN , 1 ) ;
195
+ pageScope . myDate = null ;
196
+ pageScope . $apply ( ) ;
197
+
198
+ expect ( controller . ngModelCtrl . $error [ 'mindate' ] ) . toBeFalsy ( ) ;
199
+ } ) ;
200
+
201
+ it ( 'should not enforce `required` when a max-date is set' , function ( ) {
202
+ pageScope . isRequired = false ;
203
+ pageScope . maxDate = new Date ( 2015 , JAN , 1 ) ;
204
+ pageScope . myDate = null ;
205
+ pageScope . $apply ( ) ;
206
+
207
+ expect ( controller . ngModelCtrl . $error [ 'mindate' ] ) . toBeFalsy ( ) ;
208
+ } ) ;
209
+
192
210
describe ( 'inside of a form element' , function ( ) {
193
211
var formCtrl ;
194
212
You can’t perform that action at this time.
0 commit comments