-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(datepicker): input validation for min, max, and date filter #4393
Conversation
placeholder="Pick a date"> | ||
<md-error *ngIf="resultPickerModel.errors?.mdDatepickerMin">Too early!</md-error> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be easier to just use resultPickerModel.hasError('mdDatepickerMin')
src/lib/datepicker/datepicker.md
Outdated
``` | ||
|
||
In this example the user can back past 2005, but all of the dates before then will be unselectable. | ||
They will not be able to go further back in the calendar than 2000. | ||
They will not be able to go further back in the calendar than 2000. If they manually type in a date | ||
that is before the min, after the max, or filtered out the input will have validation errors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: or filtered out, the input will ...
src/lib/datepicker/datepicker.md
Outdated
Each validation property has a different error that can be checked: | ||
* A value that violates the `min` property will have a `mdDatepickerMin` error. | ||
* A value that violates the `max` property will have a `mdDatepickerMax` error. | ||
* A value that violates the `mdDatepickerFilter` property will have a `mdDatepickerFitler` error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: mdDatepickerFitler
=> mdDatepickerFilter
src/lib/datepicker/datepicker.md
Outdated
calendar past that point. | ||
A result of `true` indicates that the date is valid and a result of `false` indicates that it is | ||
not. Again this will also disable the dates on the calendar that are invalid. However, one important | ||
difference between using `mdDatepcikerFilter` vs using `min` or `max` is that filtering out all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: mdDatepcikerFilter
-> mdDatepickerFilter
(control: AbstractControl): ValidationErrors | null => { | ||
return !this._dateFilter || !control.value || this._dateFilter(control.value) ? | ||
null : {'mdDatepickerFilter': true}; | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you thought about breaking these validator functions out into their own methods or getters? This is a bit hard to scan.
comments addressed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* support validation based on date filter * add validation support for min & max * update docs to talk about validation * fix imports * address comments
* support validation based on date filter * add validation support for min & max * update docs to talk about validation * fix imports * address comments
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
No description provided.