Feature request: A way to check for empty values
See original GitHub issueAs 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:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top 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 >
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 Free
Top 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
I see what you mean @xuo, thanks for the explanation.
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?@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?