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

Add type checker to Binding interface #24

Closed
5 tasks done
andygello555 opened this issue Mar 4, 2023 · 0 comments
Closed
5 tasks done

Add type checker to Binding interface #24

andygello555 opened this issue Mar 4, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@andygello555
Copy link
Owner

andygello555 commented Mar 4, 2023

At the moment args are just assumed to be the correct type and asserted without checks. This causes panics.

  • Create a new BindingArg type that contains:
    • Required flag: whether the arg is required by Binding.Execute
    • Type: the reflect.Type of the arg
  • Add a method to the Binding interface that returns a list of BindingArgs. This should have a default implementation on bindingProto that just returns an empty list
  • Whenever bindingProto.Execute should check the args by calling the new method described above. If there are no BindingArgs returned then the args should be passed to bindingProto.Request and bindingProto.Response as is. If there are BindingArgs returned then we should check each provided argument for that type. If a provided arg does not have the correct type we will return an appropriate error

Monday.com Item ID: #4086140643

@andygello555 andygello555 added the enhancement New feature or request label Mar 4, 2023
@andygello555 andygello555 self-assigned this Mar 4, 2023
@andygello555 andygello555 added enhancement New feature or request and removed enhancement New feature or request labels Mar 4, 2023
andygello555 added a commit that referenced this issue Mar 10, 2023
- Made the Binding interface chainable and started the argument type checking with the new BindingParam type and Params() interface method #24 (09/03/2023 - 11:52:58)
- Added type checks to bindingProto.Execute #24 (09/03/2023 - 13:39:05)
- Added a way of defining BindingParams for interface values that will also be type checked by bindingProto.TypeCheckArgs #24 (10/03/2023 - 16:28:50)
- Added the api.Params function that can construct a list of BindingParams from a list of argument groupings (10/03/2023 - 16:43:24)
- Updated all the Bindings created via derivatives of the NewBinding method to set the Params method of their respective Bindings (10/03/2023 - 16:44:37)
- Added an example for the Params function (10/03/2023 - 16:44:56)
- Added a test for the Params function (10/03/2023 - 16:45:22)
- Added a test for the bindingProto.TypeCheckArgs (10/03/2023 - 16:45:39)
- Added some more fields to the BindingProto struct to aid with interface checking (10/03/2023 - 16:46:11)
- I may have gone a bit overboard with the api package... (10/03/2023 - 16:48:39)
- Moved everything to do with paginators, bindings, and params in api to their own files to tidy things up a bit (10/03/2023 - 16:56:31)
- Updated top binding for the reddit API (10/03/2023 - 18:50:55)
- Added a lot more types to the reddit API types.go file. The listingWrapper probably needs more fleshing out #2 (10/03/2023 - 18:51:38)
- Added the Binding.ArgsFromStrings interface method and implementation (10/03/2023 - 18:53:12)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant