revert gerror usage for package gvalid

This commit is contained in:
John Guo 2021-06-26 18:44:59 +08:00
parent d109706ad3
commit bb0a3e09d6

View File

@ -7,7 +7,7 @@
package gvalid package gvalid
import ( import (
"github.com/gogf/gf/errors/gerror" "errors"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@ -175,7 +175,7 @@ func (v *Validator) doCheckBuildInRules(
"max-length", "max-length",
"size": "size":
if msg := v.checkLength(valueStr, ruleKey, rulePattern, customMsgMap); msg != "" { if msg := v.checkLength(valueStr, ruleKey, rulePattern, customMsgMap); msg != "" {
return match, gerror.New(msg) return match, errors.New(msg)
} else { } else {
match = true match = true
} }
@ -186,7 +186,7 @@ func (v *Validator) doCheckBuildInRules(
"max", "max",
"between": "between":
if msg := v.checkRange(valueStr, ruleKey, rulePattern, customMsgMap); msg != "" { if msg := v.checkRange(valueStr, ruleKey, rulePattern, customMsgMap); msg != "" {
return match, gerror.New(msg) return match, errors.New(msg)
} else { } else {
match = true match = true
} }
@ -222,7 +222,7 @@ func (v *Validator) doCheckBuildInRules(
var msg string var msg string
msg = v.getErrorMessageByRule(ruleKey, customMsgMap) msg = v.getErrorMessageByRule(ruleKey, customMsgMap)
msg = strings.Replace(msg, ":format", rulePattern, -1) msg = strings.Replace(msg, ":format", rulePattern, -1)
return match, gerror.New(msg) return match, errors.New(msg)
} }
// Values of two fields should be equal as string. // Values of two fields should be equal as string.
@ -237,7 +237,7 @@ func (v *Validator) doCheckBuildInRules(
var msg string var msg string
msg = v.getErrorMessageByRule(ruleKey, customMsgMap) msg = v.getErrorMessageByRule(ruleKey, customMsgMap)
msg = strings.Replace(msg, ":field", rulePattern, -1) msg = strings.Replace(msg, ":field", rulePattern, -1)
return match, gerror.New(msg) return match, errors.New(msg)
} }
// Values of two fields should not be equal as string. // Values of two fields should not be equal as string.
@ -253,7 +253,7 @@ func (v *Validator) doCheckBuildInRules(
var msg string var msg string
msg = v.getErrorMessageByRule(ruleKey, customMsgMap) msg = v.getErrorMessageByRule(ruleKey, customMsgMap)
msg = strings.Replace(msg, ":field", rulePattern, -1) msg = strings.Replace(msg, ":field", rulePattern, -1)
return match, gerror.New(msg) return match, errors.New(msg)
} }
// Field value should be in range of. // Field value should be in range of.
@ -436,7 +436,7 @@ func (v *Validator) doCheckBuildInRules(
match = gregex.IsMatchString(`^([0-9A-Fa-f]{2}[\-:]){5}[0-9A-Fa-f]{2}$`, valueStr) match = gregex.IsMatchString(`^([0-9A-Fa-f]{2}[\-:]){5}[0-9A-Fa-f]{2}$`, valueStr)
default: default:
return match, gerror.New("Invalid rule name: " + ruleKey) return match, errors.New("Invalid rule name: " + ruleKey)
} }
return match, nil return match, nil
} }