Kord-Extensions/kord-extensions

StringConverter length validation translation keys switched

Closed this issue · 1 comments

Description

The translation keys used to throw a DiscordRelayedException in the StringConverter are switched in case a length requirement is not met.

  • minLength req not met uses the key: converters.string.error.invalid.tooLong
  • maxLength req not met uses the key: converters.string.error.invalid.tooShort

Source code

if (minLength != null && this.parsed.length < minLength) {
throw DiscordRelayedException(
context.translate(
"converters.string.error.invalid.tooLong",
replacements = arrayOf(arg, minLength)
)
)
}
if (maxLength != null && this.parsed.length > maxLength) {
throw DiscordRelayedException(
context.translate(
"converters.string.error.invalid.tooShort",
replacements = arrayOf(arg, maxLength)
)
)
}

Suggestions

Simple solution, the translation keys should be switched:

  • minLength req not met: converters.string.error.invalid.tooShort
  • maxLength req not met: converters.string.error.invalid.tooLong

Good catch, thank you!