Improve validation in trivia #5947

Merged
Vexed01 merged 16 commits from trivia-validation into V3/develop 2023-01-02 05:24:28 +01:00
Vexed01 commented 2022-12-30 15:12:04 +01:00 (Migrated from github.com)

Description of the changes

Stricter validation of custom trivia lists to match the triviaset command and more user-friendly error messages, and max score must be greater than zero in both triviaset and custom lists.

Related to comments in #5390

Edit - it may make sense to merge into #5390 or at the very least merge this to v3/develop before #5390

Have the changes in this PR been tested?

Yes

### Description of the changes Stricter validation of custom trivia lists to match the `triviaset` command and more user-friendly error messages, and max score must be greater than zero in both triviaset and custom lists. Related to comments in #5390 Edit - it may make sense to merge into #5390 or at the very least merge this to v3/develop before #5390 ### Have the changes in this PR been tested? <!-- Choose one (remove the line that doesn't apply): --> Yes <!-- If the question doesn't apply (for example, it's not a code change), choose Yes. Please respond to this question truthfully. We do not delay nor reject PRs based on the answer to this question but it allows to better review this PR. -->
Jackenmen commented 2022-12-30 16:33:46 +01:00 (Migrated from github.com)

Oh great, I was hoping this would be done eventually but I haven't made an issue yet. Will look at this soon.

Oh great, I was hoping this would be done eventually but I haven't made an issue yet. Will look at this soon.
Jackenmen (Migrated from github.com) requested changes 2022-12-30 20:25:05 +01:00
@ -43,4 +31,1 @@
}
)
_ = Translator("Trivia", __file__)
Jackenmen (Migrated from github.com) commented 2022-12-30 17:42:40 +01:00
  • delay can also be equal to 4
  • "decimal number" -> "number"
                lambda n: n >= 4.0,
                error="delay must be a positive number greater than or equal to 4",
- delay can also be equal to 4 - "decimal number" -> "number" ```suggestion lambda n: n >= 4.0, error="delay must be a positive number greater than or equal to 4", ```
Jackenmen (Migrated from github.com) commented 2022-12-30 20:23:55 +01:00

"number" is probably enough

                error="timeout must be a positive number",
"number" is probably enough ```suggestion error="timeout must be a positive number", ```
Jackenmen (Migrated from github.com) commented 2022-12-30 20:24:29 +01:00

Zero is included so the "positive number" is wrong.

                error="payout_multiplier must be a non-negative number",
Zero is included so the "positive number" is wrong. ```suggestion error="payout_multiplier must be a non-negative number", ```
Jackenmen commented 2022-12-30 23:38:25 +01:00 (Migrated from github.com)

I decided to further improve the schema error messages and would appreciate feedback about their clarity:
image
image

If you can think of more potential edge cases that might be worth checking, it would also be appreciated.

I decided to further improve the schema error messages and would appreciate feedback about their clarity: ![image](https://user-images.githubusercontent.com/6032823/210116002-5295810b-a904-4dcb-b74c-65e2c1cba09b.png) ![image](https://user-images.githubusercontent.com/6032823/210115993-1f2d98ba-cbb1-404d-83c1-45e81590ece5.png) If you can think of more potential edge cases that might be worth checking, it would also be appreciated.
Jackenmen (Migrated from github.com) reviewed 2022-12-30 23:43:55 +01:00
Jackenmen (Migrated from github.com) left a comment
No description provided.
I'm approving this (thanks for your contribution) but will wait with merging until the new year in case someone posts some suggestions.
Jackenmen (Migrated from github.com) approved these changes 2022-12-31 00:01:36 +01:00
Jackenmen (Migrated from github.com) left a comment

![](https://i.fluffy.cc/zVmg9csn3pdFq4S6hQKHKzdCl3B7cRvG.gif)
Jackenmen commented 2023-01-02 05:24:23 +01:00 (Migrated from github.com)

Happy New Year!

Happy New Year!
red-githubbot[bot] commented 2023-04-19 22:56:59 +02:00 (Migrated from github.com)

Sorry, @Jackenmen, I could not cleanly backport this to 3.4 due to a conflict. Please backport using cherry_picker on command line.

cherry_picker b493103dcb84633550865a27d867ae70c65f3ccb 3.4
Sorry, @Jackenmen, I could not cleanly backport this to `3.4` due to a conflict. Please backport using [cherry_picker](https://pypi.org/project/cherry-picker/) on command line. ``` cherry_picker b493103dcb84633550865a27d867ae70c65f3ccb 3.4 ```
red-githubbot[bot] commented 2023-04-19 23:08:03 +02:00 (Migrated from github.com)

#6046 is a backport of this pull request to Red 3.4.

#6046 is a backport of this pull request to [Red 3.4](https://github.com/Cog-Creators/Red-DiscordBot/tree/3.4).
Sign in to join this conversation.
No reviewers
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!5947
No description provided.