diff options
Diffstat (limited to 'api4/context.go')
-rw-r--r-- | api4/context.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/api4/context.go b/api4/context.go index 6a22b4103..06523152f 100644 --- a/api4/context.go +++ b/api4/context.go @@ -375,6 +375,17 @@ func (c *Context) RequireUsername() *Context { return c } +func (c *Context) RequirePostId() *Context { + if c.Err != nil { + return c + } + + if len(c.Params.PostId) != 26 { + c.SetInvalidUrlParam("post_id") + } + return c +} + func (c *Context) RequireEmail() *Context { if c.Err != nil { return c |