From c2029df9bcfa05c19cf3644f2e686da35e267c68 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Thu, 21 Nov 2024 12:13:55 +0100 Subject: [feature] Allow emoji shortcode to be 1-character length (#3556) * [feature] Allow emoji shortcode to be 1-character length * testerino fixeroni * spaghet --- internal/validate/formvalidation.go | 4 ++-- internal/validate/formvalidation_test.go | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'internal/validate') diff --git a/internal/validate/formvalidation.go b/internal/validate/formvalidation.go index e8ec3380b..207e8e05e 100644 --- a/internal/validate/formvalidation.go +++ b/internal/validate/formvalidation.go @@ -190,11 +190,11 @@ func CustomCSS(customCSS string) error { } // EmojiShortcode just runs the given shortcode through the regular expression -// for emoji shortcodes, to figure out whether it's a valid shortcode, ie., 2-30 characters, +// for emoji shortcodes, to figure out whether it's a valid shortcode, ie., 1-30 characters, // a-zA-Z, numbers, and underscores. func EmojiShortcode(shortcode string) error { if !regexes.EmojiValidator.MatchString(shortcode) { - return fmt.Errorf("shortcode %s did not pass validation, must be between 2 and 30 characters, letters, numbers, and underscores only", shortcode) + return fmt.Errorf("shortcode %s did not pass validation, must be between 1 and 30 characters, letters, numbers, and underscores only", shortcode) } return nil } diff --git a/internal/validate/formvalidation_test.go b/internal/validate/formvalidation_test.go index 7c1ff7b7f..93762cd37 100644 --- a/internal/validate/formvalidation_test.go +++ b/internal/validate/formvalidation_test.go @@ -345,7 +345,7 @@ func (suite *ValidationTestSuite) TestValidateEmojiShortcode() { }, { shortcode: "p", - ok: false, + ok: true, }, { shortcode: "pp", @@ -361,6 +361,10 @@ func (suite *ValidationTestSuite) TestValidateEmojiShortcode() { }, { shortcode: "_", + ok: true, + }, + { + shortcode: "", ok: false, }, { -- cgit v1.2.3