You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my practical programming context, there are such kind of code
functionsome_action(req,res){varvalidr=newValidr(req.body);if(req.body.phone_num){validr.validate('phone_num','phone number should be valid').isNumeric();}}
Some arguments, suck as phone_num in above code is optional. So, we only need to validate it if it exists. However, having if statement to check its existence introduce increased cyclomatic complexity.
If there an validateIfExists function to do validation only given field exists or empty. That would be great.
The text was updated successfully, but these errors were encountered:
In my practical programming context, there are such kind of code
Some arguments, suck as
phone_num
in above code is optional. So, we only need to validate it if it exists. However, havingif
statement to check its existence introduce increased cyclomatic complexity.If there an
validateIfExists
function to do validation only given field exists or empty. That would be great.The text was updated successfully, but these errors were encountered: