I am working on my express server and I am trying to validate some query parameters. For example I can have query parameter date
which might be null or be an empty string. Now the current validation is like this
if(req.query.date && req.query.date !== '')
Is there like a function or a library that I can use like _lodash
to keep things more neat?
Your solution is already neat, you can just simplify it to
if(req.query.date)
Try not overuse lodash
or other packages, you can write these things by yourself, but all these redundant packages just flood your bundle and make it heavier.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.