Skip to content

Commit

Permalink
Merge 1c6f966 into 062470d
Browse files Browse the repository at this point in the history
  • Loading branch information
keepfool committed Jul 21, 2018
2 parents 062470d + 1c6f966 commit 97e9b44
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/validator/date.js
Expand Up @@ -12,9 +12,21 @@ function date(rule, value, callback, source, options) {
}
rules.required(rule, value, source, errors, options);
if (!isEmptyValue(value)) {
rules.type(rule, value, source, errors, options);
if (value) {
rules.range(rule, value.getTime(), source, errors, options);
let dateObject;

if (typeof value === 'number') {
if (value.toString().length === 10) {
value = Number(value) * 1000;
}
dateObject = new Date(value);
} else {
dateObject = value;
}


rules.type(rule, dateObject, source, errors, options);
if (dateObject) {
rules.range(rule, dateObject.getTime(), source, errors, options);
}
}
}
Expand Down

0 comments on commit 97e9b44

Please sign in to comment.