improve codes details

This commit is contained in:
john
2019-09-13 22:08:18 +08:00
parent 141bee9c49
commit 19a856549a
4 changed files with 62 additions and 71 deletions

View File

@ -291,10 +291,7 @@ func (s *Server) Start() error {
// 打印展示路由表
func (s *Server) DumpRoutesMap() {
if s.config.DumpRouteMap && len(s.routesMap) > 0 {
// (等待一定时间后)当所有框架初始化信息打印完毕之后才打印路由表信息
gtimer.SetTimeout(100*time.Millisecond, func() {
glog.Header(false).Println(fmt.Sprintf("\n%s", s.GetRouteMap()))
})
glog.Header(false).Println(fmt.Sprintf("\n%s", s.GetRouteMap()))
}
}

View File

@ -5,8 +5,6 @@
// You can obtain one at https://github.com/gogf/gf.
// Package gvalid implements powerful and useful data/form validation functionality.
//
// 数据/表单校验.
package gvalid
import (

View File

@ -33,75 +33,73 @@ var (
// 即使参数为空(nil|"")也需要校验的规则,主要是必需规则及关联规则
mustCheckRulesEvenValueEmpty = map[string]struct{}{
"required": struct{}{},
"required-if": struct{}{},
"required-unless": struct{}{},
"required-with": struct{}{},
"required-with-all": struct{}{},
"required-without": struct{}{},
"required-without-all": struct{}{},
"same": struct{}{},
"different": struct{}{},
"in": struct{}{},
"not-in": struct{}{},
"regex": struct{}{},
"required": {},
"required-if": {},
"required-unless": {},
"required-with": {},
"required-with-all": {},
"required-without": {},
"required-without-all": {},
"same": {},
"different": {},
"in": {},
"not-in": {},
"regex": {},
}
// 所有支持的校验规则
allSupportedRules = map[string]struct{}{
"required": struct{}{},
"required-if": struct{}{},
"required-unless": struct{}{},
"required-with": struct{}{},
"required-with-all": struct{}{},
"required-without": struct{}{},
"required-without-all": struct{}{},
"date": struct{}{},
"date-format": struct{}{},
"email": struct{}{},
"phone": struct{}{},
"telephone": struct{}{},
"passport": struct{}{},
"password": struct{}{},
"password2": struct{}{},
"password3": struct{}{},
"postcode": struct{}{},
"id-number": struct{}{},
"qq": struct{}{},
"ip": struct{}{},
"ipv4": struct{}{},
"ipv6": struct{}{},
"mac": struct{}{},
"url": struct{}{},
"domain": struct{}{},
"length": struct{}{},
"min-length": struct{}{},
"max-length": struct{}{},
"between": struct{}{},
"min": struct{}{},
"max": struct{}{},
"json": struct{}{},
"integer": struct{}{},
"float": struct{}{},
"boolean": struct{}{},
"same": struct{}{},
"different": struct{}{},
"in": struct{}{},
"not-in": struct{}{},
"regex": struct{}{},
"required": {},
"required-if": {},
"required-unless": {},
"required-with": {},
"required-with-all": {},
"required-without": {},
"required-without-all": {},
"date": {},
"date-format": {},
"email": {},
"phone": {},
"telephone": {},
"passport": {},
"password": {},
"password2": {},
"password3": {},
"postcode": {},
"id-number": {},
"qq": {},
"ip": {},
"ipv4": {},
"ipv6": {},
"mac": {},
"url": {},
"domain": {},
"length": {},
"min-length": {},
"max-length": {},
"between": {},
"min": {},
"max": {},
"json": {},
"integer": {},
"float": {},
"boolean": {},
"same": {},
"different": {},
"in": {},
"not-in": {},
"regex": {},
}
// 布尔Map
boolMap = map[string]struct{}{
// true
"1": struct{}{},
"true": struct{}{},
"on": struct{}{},
"yes": struct{}{},
// false
"": struct{}{},
"0": struct{}{},
"false": struct{}{},
"off": struct{}{},
"no": struct{}{},
"1": {},
"true": {},
"on": {},
"yes": {},
"": {},
"0": {},
"false": {},
"off": {},
"no": {},
}
)

View File

@ -4,8 +4,6 @@
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
// 默认的错误消息定义。
package gvalid
// 默认规则校验错误消息(可以通过接口自定义错误消息)