Have validate accept null and undefined
See original GitHub issueJust to make life easier, it would be great if when I call uuidValidate
and pass in null
or undefined
, it returned false. Right now the compiler doesn’t allow a potentially null/undefined value to be given.
Right now I’m doing something like this:
this.route.paramMap
.pipe(
map(x => x.get('id')),
filter(x => !!x && uuidValidate(x)),
mustHaveValue(),
switchMap(x => this.clientService.get(x)),
untilDestroyed(this)
)
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
How to check for an undefined or null variable in JavaScript?
I think the most efficient way to test for "value is null or undefined " is if ( some_variable == null ){ //...
Read more >JavaScript: Check if Variable is undefined or null - Stack Abuse
There are two approaches you can opt for when checking whether a variable is undefined or null in vanilla JavaScript.
Read more >null - JavaScript - MDN Web Docs - Mozilla
The null value represents the intentional absence of any object value. ... When checking for null or undefined , beware of the differences...
Read more >JavaScript Program To Check If A Variable Is undefined or null
The typeof operator for undefined value returns undefined . Hence, you can check the undefined value using typeof operator. Also, null values are...
Read more >Documentation - TypeScript 2.0
In strict null checking mode, the null and undefined values are not in the domain of every type and are only assignable to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
some more refs:
https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates https://stackoverflow.com/q/40081332/148072
Reopening as this may be solved in #654.