This repository was archived by the owner on May 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Why discard Booleans in parse? #78
Copy link
Copy link
Open
Description
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.
Metadata
Metadata
Assignees
Labels
No labels