@@ -116,9 +116,6 @@ export class MdDatepickerInput<D> implements AfterContentInit, ControlValueAcces
116116 this . _dateFormats . parse . dateInput ) ;
117117 }
118118 set value ( value : D | null ) {
119- if ( value != null && ! this . _dateAdapter . isDateObject ( value ) ) {
120- throw Error ( 'Datepicker: value not recognized as a date object by DateAdapter.' ) ;
121- }
122119 let oldDate = this . value ;
123120 this . _renderer . setProperty ( this . _elementRef . nativeElement , 'value' ,
124121 value ? this . _dateAdapter . format ( value , this . _dateFormats . display . dateInput ) : '' ) ;
@@ -170,16 +167,22 @@ export class MdDatepickerInput<D> implements AfterContentInit, ControlValueAcces
170167
171168 private _datepickerSubscription : Subscription ;
172169
170+ /** The form control validator for whether the input parses. */
171+ private _parseValidator : ValidatorFn = ( control : AbstractControl ) : ValidationErrors | null => {
172+ return ( ! control . value || this . _dateAdapter . isValidDate ( control . value ) ) ?
173+ null : { 'mdDatepickerParse' : true } ;
174+ }
175+
173176 /** The form control validator for the min date. */
174177 private _minValidator : ValidatorFn = ( control : AbstractControl ) : ValidationErrors | null => {
175- return ( ! this . min || ! control . value ||
178+ return ( ! this . min || ! this . _dateAdapter . isValidDate ( this . min ) || ! control . value ||
176179 this . _dateAdapter . compareDate ( this . min , control . value ) <= 0 ) ?
177180 null : { 'mdDatepickerMin' : { 'min' : this . min , 'actual' : control . value } } ;
178181 }
179182
180183 /** The form control validator for the max date. */
181184 private _maxValidator : ValidatorFn = ( control : AbstractControl ) : ValidationErrors | null => {
182- return ( ! this . max || ! control . value ||
185+ return ( ! this . max || ! this . _dateAdapter . isValidDate ( this . max ) || ! control . value ||
183186 this . _dateAdapter . compareDate ( this . max , control . value ) >= 0 ) ?
184187 null : { 'mdDatepickerMax' : { 'max' : this . max , 'actual' : control . value } } ;
185188 }
@@ -192,7 +195,8 @@ export class MdDatepickerInput<D> implements AfterContentInit, ControlValueAcces
192195
193196 /** The combined form control validator for this input. */
194197 private _validator : ValidatorFn | null =
195- Validators . compose ( [ this . _minValidator , this . _maxValidator , this . _filterValidator ] ) ;
198+ Validators . compose (
199+ [ this . _parseValidator , this . _minValidator , this . _maxValidator , this . _filterValidator ] ) ;
196200
197201 constructor (
198202 private _elementRef : ElementRef ,
0 commit comments