summaryrefslogtreecommitdiffstats
path: root/api4/context.go
diff options
context:
space:
mode:
Diffstat (limited to 'api4/context.go')
-rw-r--r--api4/context.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/api4/context.go b/api4/context.go
index 7ad6f30b4..6a22b4103 100644
--- a/api4/context.go
+++ b/api4/context.go
@@ -359,6 +359,22 @@ func (c *Context) RequireChannelId() *Context {
return c
}
+func (c *Context) RequireUsername() *Context {
+ if c.Err != nil {
+ return c
+ }
+
+ if len(c.Params.Username) < 3 {
+ c.SetInvalidUrlParam("username")
+ }
+
+ if len(c.Params.Username) > 22 {
+ c.SetInvalidUrlParam("username")
+ }
+
+ return c
+}
+
func (c *Context) RequireEmail() *Context {
if c.Err != nil {
return c
@@ -371,3 +387,4 @@ func (c *Context) RequireEmail() *Context {
return c
}
+