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
fix issue 210: custom values formatting schema #249
Conversation
@@ -250,7 +279,9 @@ function parse(input, options) { | |||
return ret; | |||
} | |||
|
|||
return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too much logic in the return
statement makes it hard to understand what's actually returned from the function.
if (typeof typedSchemaFormatter === 'function') { | ||
return typedSchemaFormatter; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should throw if the typedSchemaFormatter
type is not a supported type.
baz: 3 | ||
}; | ||
t.deepEqual(actual, expected); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feature will need a lot more tests.
``` | ||
*/ | ||
readonly types?: { | ||
[key: string]: 'string' | 'number' | CustomValueParser; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[key: string]: 'string' | 'number' | CustomValueParser; | |
[type: string]: 'string' | 'number' | CustomValueParser; |
queryString.parse('foo=1&bar=1&baz=1.5', { | ||
types: { | ||
foo: 'string', | ||
bar: 'number', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about an array of string or array of numbers? We should probably use the notation string[]
and number[]
for those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree
Co-Authored-By: Sindre Sorhus <sindresorhus@gmail.com>
Co-Authored-By: Sindre Sorhus <sindresorhus@gmail.com>
Sorry, I've just realized unfortunately I have no spare time to finish the PR. If someone is willing to finish - it'd cool to finally deliver this functionality. |
Resolves #210