Skip to content

v0.9.0 Custom validators!

Pre-release
Pre-release
Compare
Choose a tag to compare
@Rodentman87 Rodentman87 released this 17 May 22:32
· 21 commits to main since this release
6dbe74e

This release adds the ability to specify a custom validator for any option. When the command is run by a user, each option will first be passed to the validator for that option if one exists, then it will be passed to the transformer if one exists and the value was valid, then it's added to the options object. If there are any validation errors for the command, the run function wont be called and instead the user will receive an ephemeral reply listing all the validation errors. To specify a validator function for an option, just pass a function that will take the CommandInteration and the value and either return true for valid values or return a string containing the error message for invalid values. Instead of returning a string you can also throw a ValidationError and the error message will be used.

This release also cleans up the types quite a bit for all the options and makes types more specific for channel options when you pass a list of channelTypes.