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

Option to parse all values as strings #516

Closed
alanhett opened this issue Nov 17, 2022 · 6 comments
Closed

Option to parse all values as strings #516

alanhett opened this issue Nov 17, 2022 · 6 comments

Comments

@alanhett
Copy link

I need an option that will disable number parsing and parse all values as strings. For example, zip codes and tax ID numbers often have leading zeroes that need to be preserved as string types.

I'm thinking of a simple solution, and I'm willing to submit the PR myself, but would like to share my idea here for feedback first. The option property would be something like:

numberParseDisable: true (which is similar naming to the numberParseOptions property). If set to true, it would bypass the strnum process.

Thoughts? Any guidance on what source files I should review and/or update to build this would be helpful!

@github-actions
Copy link

I'm glad you find this repository helpful. I'll try to address your issue ASAP. You can watch the repo for new changes or star it.

@amitguptagwl
Copy link
Member

You're using the old version of library. Please refer the documentation for v4.

@alanhett
Copy link
Author

alanhett commented Nov 22, 2022

Thanks, I did have the correct version, but I was confused by the options. These options preserve leading zeroes, but it does not disable number parsing entirely (e.g., numbers without leading zeroes will still be parsed as numbers). I'm still willing to write the above if others are interested in such an option.

numberParseOptions: { leadingZeros: false }

@amitguptagwl
Copy link
Member

Please check strnum library that we use in FXP for value parsing.

@abnaod
Copy link

abnaod commented Dec 22, 2022

This works for me

numberParseOptions: {
   leadingZeros: false,
   hex: false,
   skipLike: /\d/,
 } 

@weijarz
Copy link

weijarz commented Jul 7, 2023

I think skipLike: /(?:)/ is a better option.

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

No branches or pull requests

4 participants