Skip to content

Comments

fix issue 210: custom values formatting schema#249

Closed
MaxDonchenko wants to merge 8 commits intosindresorhus:masterfrom
MaxDonchenko:issues/210
Closed

fix issue 210: custom values formatting schema#249
MaxDonchenko wants to merge 8 commits intosindresorhus:masterfrom
MaxDonchenko:issues/210

Conversation

@MaxDonchenko
Copy link

Resolves #210

return ret;
}

return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => {
Copy link
Author

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;
}

Copy link
Owner

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);
});
Copy link
Owner

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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[key: string]: 'string' | 'number' | CustomValueParser;
[type: string]: 'string' | 'number' | CustomValueParser;

queryString.parse('foo=1&bar=1&baz=1.5', {
types: {
foo: 'string',
bar: 'number',
Copy link
Owner

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree

@MaxDonchenko
Copy link
Author

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.

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

Successfully merging this pull request may close these issues.

Support predefining types

2 participants