-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
fix(builders): add proper snowflake validation #11290
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(builders): add proper snowflake validation #11290
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Jiralite
left a comment
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.
I believe this should accept a snowflake too:
| id: z.union([z.string(), z.number()]), |
| public setId(id: Snowflake | number): this { |
|
@rie03p looks like something is not quite right because tests are failing, may need to update them? |
|
@Jiralite You're right! The validation is now working correctly and rejecting invalid IDs like 'hi!' and '0'. I've updated the existing tests to use valid IDs (numbers or proper snowflakes) so they pass with the new validation. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11290 +/- ##
==========================================
+ Coverage 43.61% 43.62% +0.01%
==========================================
Files 375 375
Lines 19338 19340 +2
Branches 1880 1880
==========================================
+ Hits 8434 8437 +3
+ Misses 10891 10890 -1
Partials 13 13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Almeida <[email protected]>
|
I’ve fixed the tests that were failing. |
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.
0 is perfectly valid in a snowflake, and could increase the limit too
Co-authored-by: Jiralite <[email protected]>
close #11289
Please describe the changes this PR makes and why it should be merged:
This PR adds proper Snowflake validation to the builders package. Previously, multiple instances were using plain
z.string()for Snowflake IDs, which didn't validate that the values are numeric strings as required by Discord's Snowflake format.Changes:
snowflakePredicate(z.string().regex(/^\d{17,20}$/)) to validate Snowflake formatz.string()withsnowflakePredicatein:emojiPredicate.idbuttonPremiumPredicate.sku_iddefault_values.idfor channel, mentionable, role, and user select menu predicatesStatus and versioning classification: