question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Should .exists() check for null values as well?

See original GitHub issue

Currently the .exists() validator only checks for undefined, does it make sense to add an option to also check for null? Something like: check('id').exists({ checkFalsy: true }) //or check('id').exists({ checkNull: true })

or should we be using a different validator like notEmpty() or not().optional() ?

Thanks so much for your help.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
gustavohenkecommented, Apr 30, 2018

@sant123 false or 0 would succeed when check with .not().isEmpty(), as it will only check the string representation of the value has something in it (null and undefined are both represented as an empty string).

A checkFalsy option for exists would work differently, failing the validation if the value is falsy.

0reactions
lock[bot]commented, May 31, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Should one check for null if he does not expect null?
In this case it is OK to have a null value. Method m1() should check it as any other value: there is no...
Read more >
Is it necessary to test for NULL if also testing for greater than?
My understanding is that if @Test is NULL , then it has no value, and is not greater than, less than or even...
Read more >
Working with SQL NULL values
This article will show functions and operators for handling SQL NULL values.
Read more >
Checking If Any Value is NaN in a Pandas DataFrame
Within pandas, a null value is considered missing and is denoted by NaN. This article details how to evalute pandas for missing data...
Read more >
NULL semantics - Azure Databricks
In Azure Databricks, IN and NOT IN expressions are allowed inside a WHERE clause of a query. Unlike the EXISTS expression, IN expression...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found