Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question\Enhancement - {parseNumbers: true} when a number isn't a number #201

Closed
Desmodue opened this issue Aug 8, 2019 · 2 comments
Closed

Comments

@Desmodue
Copy link

Desmodue commented Aug 8, 2019

Hi

Probably an edge case but I have some data that is a number but needs to be treated as a string and also data that is a number but needs to remain as a number. So I do need parseNumbers: true.

example postcode=01220
.parse returns { postcode : 1220 }
Which is now invalid.What I would like is { postcode : '01220' }

Another example is telephone number
telephone=012345678
.parse returns { telephone: 12345678 } would like { telephone: '012345678' }

What would be nice is the ability to prefix the value so that it is treated as a string and the prefix stripped ?
option {parseNumbers: true, treatAsTextPrefix: '<'}

telephone=<012345678 would result in { telephone: '012345678'

Or is there some other way to achieve this?

@sindresorhus
Copy link
Owner

Just don't use the parseNumbers option and parse the string properties yourself. Then you have full control. I'm not gonna add a treatAsTextPrefix option.

@smenshikov
Copy link

I have the same case where I need to avoid bringing few fields to a number. This feature could be very useful

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

No branches or pull requests

3 participants