From 2382eed21d1b8d9727a062a51137f9d920364d3d Mon Sep 17 00:00:00 2001 From: Roman Minkin Date: Fri, 9 Oct 2015 17:17:16 -0400 Subject: [PATCH] Add `c.PostFormExists(key)` method which returns `true` if field with given name exists in the form --- context.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/context.go b/context.go index b784c14b..0443dd97 100644 --- a/context.go +++ b/context.go @@ -198,6 +198,13 @@ func (c *Context) PostForm(key string) (va string) { return } +// PostFormExists returns `true` if field with given name exists in the form +func (c *Context) PostFormExists(key string) (exists bool) { + _, exists = c.postForm(key) + + return exists +} + // Param is a shortcut for c.Params.ByName(key) func (c *Context) Param(key string) string { return c.Params.ByName(key)