Tweak date validation logic for months and days
- valid months should be between 1 and 12, inclusive - days should be between 1 and 31, inclusive - swap a few lets for consts
This commit is contained in:
parent
0cee3c9959
commit
295088524c
@ -84,21 +84,19 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
isMonthValid: function() {
|
isMonthValid: function() {
|
||||||
let _month = parseInt(this.month)
|
const month = parseInt(this.month)
|
||||||
let valid = _month >= 0 && _month <= 12
|
return month >= 1 && month <= 12
|
||||||
return valid
|
|
||||||
},
|
},
|
||||||
|
|
||||||
isDayValid: function() {
|
isDayValid: function() {
|
||||||
let _day = parseInt(this.day)
|
const day = parseInt(this.day)
|
||||||
let valid = _day >= 0 && _day <= this.daysMaxCalculation
|
return day >= 1 && day <= this.daysMaxCalculation
|
||||||
return valid
|
|
||||||
},
|
},
|
||||||
|
|
||||||
isYearValid: function() {
|
isYearValid: function() {
|
||||||
let valid
|
let valid
|
||||||
let minYear = this.mindate ? parseInt(this.mindate) : null
|
const minYear = this.mindate ? parseInt(this.mindate) : null
|
||||||
let maxYear = this.maxdate ? parseInt(this.maxdate) : null
|
const maxYear = this.maxdate ? parseInt(this.maxdate) : null
|
||||||
|
|
||||||
if (minYear && maxYear) {
|
if (minYear && maxYear) {
|
||||||
valid = this.year >= minYear && this.year <= maxYear
|
valid = this.year >= minYear && this.year <= maxYear
|
||||||
@ -151,14 +149,12 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
return 29
|
return 29
|
||||||
}
|
}
|
||||||
break
|
|
||||||
|
|
||||||
case 4: // April
|
case 4: // April
|
||||||
case 6: // June
|
case 6: // June
|
||||||
case 9: // September
|
case 9: // September
|
||||||
case 11: // November
|
case 11: // November
|
||||||
return 30
|
return 30
|
||||||
break
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// All other months, or null, go with 31
|
// All other months, or null, go with 31
|
||||||
|
Loading…
x
Reference in New Issue
Block a user