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

Parser converting number-like strings to numbers? #17

Open
CaribouColin opened this issue Apr 18, 2022 · 1 comment
Open

Parser converting number-like strings to numbers? #17

CaribouColin opened this issue Apr 18, 2022 · 1 comment

Comments

@CaribouColin
Copy link

CaribouColin commented Apr 18, 2022

One of our endpoints accepts XML and parses it into a JS object. Part of the data that it receives includes a zip code. It appears that this parser is seeing what looks like a number and converting it into an int even though zip codes should be treated as strings. Is there a way to disable the automatic parsing of values?

UPDATE: I tried setting the attribute parsing value to false but it seems to be completely ignoring the option.

fastifyServer.register(require('fastify-xml-body-parser'), {
  parseAttributeValue: false,
})

Example Data:

<PostalCode>02108</PostalCode>
console.log(request.body); // { PostalCode: 2108 }
@amitguptagwl
Copy link
Member

@CaribouColin this package is using FXP v4 now. It means you can set numberparseoptions to manipulate the parsing result.

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

2 participants