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.

Feature request: A way to check for empty values

See original GitHub issue

As far as i can tell, there currently doesn’t seem to be a way to check if a value is empty or not - which seems like a basic feature for a library like this.

Especially when working with .env.example files you sometimes run into issues where someone might forget to fill out some values - having a way to ensure that the original value (before type coercion) is not empty, would be awesome.

I’ve tried using a extraAccessors (e.g. asStringNotEmpty()) but the extraAccessors doesn’t get called when the property is undefined and extraAccessors are not chainable with required().

I’d be happy to work on a PR for this, but hear some thoughts first as to how to implement this or if you would want to consider implementing this feature at all.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
evanshortisscommented, Nov 18, 2019

I see what you mean @xuo, thanks for the explanation.

Ideally .required() itself would either check if the string is empty

I feel like this is the correct solution. If a variable is required it should be a non-empty (i.e length >= 1) string in process.env. Maybe some recent contributors have an opinion:

@todofixthis @shawnmclean @rmblstrp, any objections to required() being changed to throw if a variable is defined as an empty string?

1reaction
evanshortisscommented, Nov 20, 2019

@todofixthis that’s good feedback since you’ve been bitten by something similar before, thank you!

@xuo let’s make the change so that required() throws an error if the variable is set to an empty string. Do you want to open a PR?

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Feature request] Variables: Allow empty value #5970 - GitHub
The best workaround for a variable $name which is "empty" i could find is to use the output type json in combination with...
Read more >
arcpy - How to check for empty values in fields of a featureclass?
The field name here is "Stand". The following code doesn´t seem to work as "Test" is printed for every feature class even when...
Read more >
Get a list of features which contain empty values (python ...
I am trying to clean a dataset and basically get rid of all the features which have a certain amount of empty values,...
Read more >
How do I query items_by_column_values where the value is ...
How do I query items_by_column_values where the value is null (None)? In particular, I am interested in column types of status and link....
Read more >
When reading from empty cells variables take default values
I have a test with variables which were assigned default values. This test is used in a suite where the variables take values...
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