Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit bfb063fa
authored
Aug 24, 2017
by
John Schulz
Committed by
Sushant
Aug 24, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(validations): prevent deprecation warning in isDate (#8179)
1 parent
2a1e5064
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
lib/utils/validator-extras.js
lib/utils/validator-extras.js
View file @
bfb063f
...
@@ -93,8 +93,19 @@ validator.isNull = validator.isEmpty;
...
@@ -93,8 +93,19 @@ validator.isNull = validator.isEmpty;
// isDate removed in 7.0.0
// isDate removed in 7.0.0
// https://github.com/chriso/validator.js/commit/095509fc707a4dc0e99f85131df1176ad6389fc9
// https://github.com/chriso/validator.js/commit/095509fc707a4dc0e99f85131df1176ad6389fc9
validator
.
isDate
=
function
(
dateString
)
{
validator
.
isDate
=
function
(
dateString
)
{
return
moment
(
dateString
).
isValid
();
// avoid http://momentjs.com/guides/#/warnings/js-date/
// by doing a preliminary check on `dateString`
const
parsed
=
Date
.
parse
(
dateString
);
if
(
isNaN
(
parsed
))
{
// fail if we can't parse it
return
false
;
}
else
{
// otherwise convert to ISO 8601 as moment prefers
// http://momentjs.com/docs/#/parsing/string/
const
date
=
new
Date
(
parsed
);
return
moment
(
date
.
toISOString
()).
isValid
();
}
};
};
exports
.
validator
=
validator
;
exports
.
validator
=
validator
;
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment