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 b10ea7a9b..cdb9f83db 100644 --- a/api4/context.go +++ b/api4/context.go @@ -641,3 +641,26 @@ func (c *Context) RequireActionId() *Context { } return c } + +func (c *Context) RequireRoleId() *Context { + if c.Err != nil { + return c + } + + if len(c.Params.RoleId) != 26 { + c.SetInvalidUrlParam("role_id") + } + return c +} + +func (c *Context) RequireRoleName() *Context { + if c.Err != nil { + return c + } + + if !model.IsValidRoleName(c.Params.RoleName) { + c.SetInvalidUrlParam("role_name") + } + + return c +} |