summaryrefslogtreecommitdiffstats
path: root/api4/context.go
diff options
context:
space:
mode:
Diffstat (limited to 'api4/context.go')
-rw-r--r--api4/context.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/api4/context.go b/api4/context.go
index f0d8b0c5c..c30a975f2 100644
--- a/api4/context.go
+++ b/api4/context.go
@@ -431,3 +431,27 @@ func (c *Context) RequireEmail() *Context {
return c
}
+
+func (c *Context) RequireCategory() *Context {
+ if c.Err != nil {
+ return c
+ }
+
+ if !model.IsValidAlphaNum(c.Params.Category, true) {
+ c.SetInvalidUrlParam("category")
+ }
+
+ return c
+}
+
+func (c *Context) RequirePreferenceName() *Context {
+ if c.Err != nil {
+ return c
+ }
+
+ if !model.IsValidAlphaNum(c.Params.PreferenceName, true) {
+ c.SetInvalidUrlParam("preference_name")
+ }
+
+ return c
+}