diff options
Diffstat (limited to 'api4/context.go')
-rw-r--r-- | api4/context.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/api4/context.go b/api4/context.go index 847a8d55f..f492f2b99 100644 --- a/api4/context.go +++ b/api4/context.go @@ -382,6 +382,17 @@ func (c *Context) RequirePostId() *Context { return c } +func (c *Context) RequireAppId() *Context { + if c.Err != nil { + return c + } + + if len(c.Params.AppId) != 26 { + c.SetInvalidUrlParam("app_id") + } + return c +} + func (c *Context) RequireFileId() *Context { if c.Err != nil { return c @@ -464,6 +475,18 @@ func (c *Context) RequireCategory() *Context { return c } +func (c *Context) RequireService() *Context { + if c.Err != nil { + return c + } + + if len(c.Params.Service) == 0 { + c.SetInvalidUrlParam("service") + } + + return c +} + func (c *Context) RequirePreferenceName() *Context { if c.Err != nil { return c |