提交 dd44876e 编写于 作者: martianzhang's avatar martianzhang

timeFormatCheck add new test cases

上级 cb63ad79
......@@ -376,7 +376,7 @@ func timeFormatCheck(t string) bool {
// 不允许为空,但允许时间前后有空格
t = strings.TrimSpace(t)
// 仅允许 数字、减号、冒号、空格
allowChars := regexp.MustCompile(`^[\-0-9: ]+$`)
allowChars := regexp.MustCompile(`^[\-0-9:. ]+$`)
return allowChars.MatchString(t)
}
......
......@@ -156,6 +156,9 @@ func TestRuleEqualLike(t *testing.T) {
func TestTimeFormatError(t *testing.T) {
rightTimes := []string{
`2020-01-01`,
`2020-01-01 23:59:59`,
`2020-01-01 23:59:59.0`, // 0ms
`2020-01-01 23:59:59.123`, // 123ms
}
for _, rt := range rightTimes {
if !timeFormatCheck(rt) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册