twilight_validate::command

Function option_name

source
pub fn option_name(value: impl AsRef<str>) -> Result<(), CommandValidationError>
Expand description

Validate the name of a CommandOption.

The length of the name must be more than NAME_LENGTH_MIN and less than or equal to NAME_LENGTH_MAX. It can only contain alphanumeric characters and lowercase variants must be used where possible. Special characters - and _ are allowed.

ยงErrors

Returns an error of type NameLengthInvalid if the length is invalid.

Returns an error of type NameCharacterInvalid if the name contains a non-alphanumeric character or an uppercase character for which a lowercase variant exists.