-
-
Notifications
You must be signed in to change notification settings - Fork 279
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
checkFalsePositiveDate(dateString = '') breaks IE #404
Comments
@domehead100 can you please supply example code, I am not sure what you are stating here is the issue |
Sorry, in a hurry. In rules.js: // --> default paramater in the line below breaks IE
function checkFalsePositiveDates(dateString = '') {
// --> if null is passed in, it will not get replaced with empty string, and the line below will error
if (dateString.length === 10) {
// massage input to use yyyy-mm-dd format
// we support yyyy/mm/dd or yyyy.mm.dd
let normalizedDate = dateString.replace('.', '-').replace('/', '-');
let parts = normalizedDate.split('-');
if (parts.length === 3) {
if (parts[0].length === 4) {
// yyyy-mm-dd format
let y = parseInt(parts[0]);
let m = parseInt(parts[1]);
let d = parseInt(parts[2]);
if (m === 2) {
// return leapYear(y) ? d <= 29 : d <= 28;
if (leapYear(y)) {
if (d > 29) {
return false;
}
} else {
if (d > 28) {
return false;
}
}
}
if (m === 4 || m === 6 || m === 9 || m === 11) {
if (d > 30) {
return false;
}
}
}
}
return true; // we are not in feburary, proceed
}
return true; // we are not testing formatted date, proceed to rest of validation
} |
I understand the code referenced above, it has been in place for many years. Can you provide the validation code in question. I am keen to adjust, but need some more detail when it “blows up” |
andreyelpaev
pushed a commit
to andreyelpaev/validatorjs
that referenced
this issue
Mar 11, 2021
andreyelpaev
pushed a commit
to andreyelpaev/validatorjs
that referenced
this issue
Mar 11, 2021
andreyelpaev
pushed a commit
to andreyelpaev/validatorjs
that referenced
this issue
Mar 11, 2021
andreyelpaev
pushed a commit
to andreyelpaev/validatorjs
that referenced
this issue
Mar 12, 2021
Fixed in 3.5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
IE breaks on default parameters for functions. Better to null check inside the body. Also default params only replace the missing param if it is undefined, whereas null would not get replaced, causing the code to blow up inside the function body.
The text was updated successfully, but these errors were encountered: