Skip to content
This repository has been archived by the owner on May 1, 2021. It is now read-only.

Enable serialising empty string as object values #13

Merged
merged 3 commits into from
Jan 10, 2020

Conversation

georgek
Copy link
Contributor

@georgek georgek commented Jan 8, 2020

I find it useful to be able to handle empty strings in objects. I'm not aware of any reason to not support it.

@pbeshai
Copy link
Owner

pbeshai commented Jan 8, 2020

For now, I'd recommend just creating your own param type and using it instead of the default if you want this behavior.

@georgek
Copy link
Contributor Author

georgek commented Jan 10, 2020

Is there any reason not to support it? With the current behaviour it's essentially required to remove keys whenever the value is an empty string. If not, there is very strange behaviour because an object {key: ""} will deserialise as {key: undefined}. If we allow empty strings then users can still remove the key if they wish, but the above object will still deserialise properly.

@pbeshai
Copy link
Owner

pbeshai commented Jan 10, 2020

The main problem is its a breaking change, but we can just version it appropriately. I think you're right we should allow it. Can you add a test for this situation?

@georgek
Copy link
Contributor Author

georgek commented Jan 10, 2020

I've added some tests and also some for strings with hyphens in.

@pbeshai
Copy link
Owner

pbeshai commented Jan 10, 2020

Thanks!

@pbeshai pbeshai merged commit c2d27bd into pbeshai:master Jan 10, 2020
@pbeshai
Copy link
Owner

pbeshai commented Jan 10, 2020

In v0.3.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants