Skip to content

Commit

Permalink
refactor(date-picker): remove redundant code (#4863)
Browse files Browse the repository at this point in the history
* refactor(date-picker): remove redundant code

* fix(datepicker): add report invalid date in range
  • Loading branch information
danielsogl authored and valorkin committed Dec 13, 2018
1 parent 92efe9a commit bf07304
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/datepicker/bs-daterangepicker-input.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,15 @@ export class BsDaterangepickerInputDirective
return null;
}

const _isFirstDateValid = isDateValid(_value[0]);
const _isSecondDateValid = isDateValid(_value[1]);

const _isDateValid = isDateValid(_value[0]) && isDateValid(_value[0]);
if (!_isFirstDateValid) {
return { bsDate: { invalid: _value[0] } };
}

if (!_isDateValid) {
return { bsDate: { invalid: _value } };
if (!_isSecondDateValid) {
return { bsDate: { invalid: _value[1] } };
}

if (this._picker && this._picker.minDate && isBefore(_value[0], this._picker.minDate, 'date')) {
Expand Down

0 comments on commit bf07304

Please sign in to comment.