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

Why discard Booleans in parse? #78

Open
edgracilla opened this issue Nov 1, 2019 · 0 comments
Open

Why discard Booleans in parse? #78

edgracilla opened this issue Nov 1, 2019 · 0 comments

Comments

@edgracilla
Copy link

The following test will fail, since it totally disallow the non-string values (stated in test.js line 520)

it('return boolean as boolean', () => {
  query = mqs.parse({
    foo: true,
    bar: false,
  });
  assert.deepEqual(query, {
    foo: true,
    bar: false,
  });
});

But here is my use case, I'm using fastify and utilized their integrated ajv as my validator. My ajv was configured to do a type coercion, hence, if I pass the following query ?foo=true&bar=false the returned value from validator are boolean values.

{
  foo: true,
  bar: false
}

If I pass this to mqs.parse() it returns an empty object since mqs totally disallow bool values.

Turning off the coercion is not an option for me. And converting it back to string is a dirty hack. I guess it might be good if this will allow by mqs itself.

I can send a PR and test, but I want to know the importance of discarding the boolean values in test.js line 520, if there's any.

edgracilla added a commit to edgracilla/node-mongo-querystring that referenced this issue Nov 1, 2019
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

1 participant