add some validator for hostFieldNew

This commit is contained in:
Ulric Qin 2020-10-25 20:06:46 +08:00
parent 8c6726800f
commit e5b95921cf
1 changed files with 16 additions and 0 deletions

View File

@ -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))
}