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

Make filter type parameters mutually exclusive #4

Open
akshgpt7 opened this issue Apr 28, 2020 · 0 comments
Open

Make filter type parameters mutually exclusive #4

akshgpt7 opened this issue Apr 28, 2020 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@akshgpt7
Copy link
Owner

akshgpt7 commented Apr 28, 2020

For some methods, there are some parameters which are of the filter type, implying that exactly one of them has to be passed for one request. Example of filters: https://developers.google.com/youtube/v3/docs/activities/list#parameters.

This requires checking 2 things:

  • At least one of the filters has been passed (filters cannot be 0 in number).
  • Not more than one filter is passed (hence, mutually exclusive).

Currently there's no way to raise an error if the user enters more than one filter, or enters 0 filters.
This is a bit tricky to implement, and I've not yet found the correct approach to make this happen. The filters are clearly distinguished in the API docs for each method.

The basic idea is to make the client library prompt the user/raise an error before the request is made if they have passed more than one filter/haven't passed any filter.
As of now, I could only think of making some kind of custom filter type, and check if exactly one parameter of the filter type exists in the params passed by the user (There can also be a better approach than this).

Supporting mutually exclusive groups has been opened as an issue in TypeScript itself, but it was rejected (microsoft/TypeScript#38120, microsoft/TypeScript#14094).

@akshgpt7 akshgpt7 added the help wanted Extra attention is needed label Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant