From e5b95921cf1e04d6b15374dc0a7fcf9dfac298c9 Mon Sep 17 00:00:00 2001 From: Ulric Qin Date: Sun, 25 Oct 2020 20:06:46 +0800 Subject: [PATCH] add some validator for hostFieldNew --- src/modules/ams/http/router_host_field.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/modules/ams/http/router_host_field.go b/src/modules/ams/http/router_host_field.go index a625a658..8409fe4a 100644 --- a/src/modules/ams/http/router_host_field.go +++ b/src/modules/ams/http/router_host_field.go @@ -12,6 +12,22 @@ func hostFieldNew(c *gin.Context) { var obj models.HostField bind(c, &obj) + if obj.FieldIdent == "" { + bomb("field_ident is blank") + } + + if obj.FieldName == "" { + bomb("field_name is blank") + } + + if obj.FieldType == "" { + bomb("field_type is blank") + } + + if obj.FieldCate == "" { + obj.FieldCate = "Default" + } + renderMessage(c, models.HostFieldNew(&obj)) } -- GitLab