summaryrefslogtreecommitdiff
path: root/internal/util/validation.go
diff options
context:
space:
mode:
authorLibravatar Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com>2021-04-19 19:42:19 +0200
committerLibravatar GitHub <noreply@github.com>2021-04-19 19:42:19 +0200
commit32c5fd987a06e11b14a4247d13187657c14adedd (patch)
treef5b787ca0f020bea5fd020925e52d3592a77a6ad /internal/util/validation.go
parentApi/v1/accounts (#8) (diff)
downloadgotosocial-32c5fd987a06e11b14a4247d13187657c14adedd.tar.xz
Api/v1/statuses (#11)
This PR adds: Statuses New status creation. View existing status Delete a status Fave a status Unfave a status See who's faved a status Media Upload media attachment and store/retrieve it Upload custom emoji and store/retrieve it Fileserver Serve files from storage Testing Test models, testrig -- run a GTS test instance and play around with it.
Diffstat (limited to 'internal/util/validation.go')
-rw-r--r--internal/util/validation.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/internal/util/validation.go b/internal/util/validation.go
index 88a56875c..8102bc35d 100644
--- a/internal/util/validation.go
+++ b/internal/util/validation.go
@@ -142,3 +142,13 @@ func ValidatePrivacy(privacy string) error {
// TODO: add some validation logic here -- length, characters, etc
return nil
}
+
+// ValidateEmojiShortcode 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,
+// lowercase a-z, numbers, and underscores.
+func ValidateEmojiShortcode(shortcode string) error {
+ if !emojiShortcodeRegex.MatchString(shortcode) {
+ return fmt.Errorf("shortcode %s did not pass validation, must be between 2 and 30 characters, lowercase letters, numbers, and underscores only", shortcode)
+ }
+ return nil
+}