diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2018-10-24 19:17:30 +0300 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2018-10-25 19:46:45 +0300 |
commit | 6bf2cb91bb5fa893746e905528467462e044e5ec (patch) | |
tree | 86db692a6cc8f4cbf077af57244d1729becf309c /app/assets/javascripts/vue_shared/components/gl_countdown.vue | |
parent | 6e680647c23cfdbad8624703f8eb49dcf9474c7e (diff) |
Add validation for date strings passed to GlCountdown
Diffstat (limited to 'app/assets/javascripts/vue_shared/components/gl_countdown.vue')
-rw-r--r-- | app/assets/javascripts/vue_shared/components/gl_countdown.vue | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/app/assets/javascripts/vue_shared/components/gl_countdown.vue b/app/assets/javascripts/vue_shared/components/gl_countdown.vue index bc42d4611b3..9327a2a4a6c 100644 --- a/app/assets/javascripts/vue_shared/components/gl_countdown.vue +++ b/app/assets/javascripts/vue_shared/components/gl_countdown.vue @@ -6,9 +6,12 @@ import { calculateRemainingMilliseconds, formatTime } from '~/lib/utils/datetime */ export default { props: { - endDate: { + endDateString: { type: String, required: true, + validator(value) { + return !Number.isNaN(new Date(value).getTime()); + }, }, }, @@ -21,7 +24,7 @@ export default { mounted() { const updateRemainingTime = () => { - const remainingMilliseconds = calculateRemainingMilliseconds(this.endDate); + const remainingMilliseconds = calculateRemainingMilliseconds(this.endDateString); this.remainingTime = formatTime(remainingMilliseconds); }; @@ -38,8 +41,8 @@ export default { <template> <time v-gl-tooltip - :datetime="endDate" - :title="endDate" + :datetime="endDateString" + :title="endDateString" > {{ remainingTime }} </time> |