Skip to content

feat: add some type asserting validation function #1117

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

wolfy1339
Copy link
Member

@wolfy1339 wolfy1339 commented Feb 24, 2025

There are 2 functions added in this commit: validateEventNameOrNames() and validatePayload()

validateEventNameOrNames() validates either an array of event names or a string event name corresponds to known events

validatePayload() validates the structure of the event object and also verifies the event name

Part of #1055


Before the change?

  • No type-safe validation was provided that would automatically cast objects to the proper types

After the change?

  • Adds type-safe validation functions that automatically type cast objects

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

There are 2 functions added in this commit: `validateEventNameOrNames()` and `validatePayload()`

`validateEventNameOrNames()` validates either an array of event names or a string event name corresponds to known events

`validatePayload()` validates the structure of the event object and also verifies the event name
@wolfy1339 wolfy1339 added the Type: Feature New feature or request label Feb 24, 2025
Copy link
Contributor

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@wolfy1339 wolfy1339 marked this pull request as draft February 25, 2025 00:25
@wolfy1339
Copy link
Member Author

These are fine for run-time checks, but fails on types.

Typescript can't seem to infer the type properly

@nickfloyd nickfloyd moved this from 🆕 Triage to 👀 In review in 🧰 Octokit Active Feb 27, 2025
@nickfloyd nickfloyd moved this from 👀 In review to 🛑 Blocked/Awaiting Response in 🧰 Octokit Active Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New feature or request
Projects
Status: 🛑 Blocked/Awaiting Response
Development

Successfully merging this pull request may close these issues.

2 participants