优化代码

This commit is contained in:
刘祥超
2022-11-29 15:33:12 +08:00
parent b2a1bef08f
commit bbcfdbbf5e
5 changed files with 8 additions and 15 deletions

View File

@@ -362,13 +362,13 @@ func (this *Rule) Test(value interface{}) bool {
return types.Float64(value) != this.floatValue
case RuleOperatorEqString:
if this.IsCaseInsensitive {
return strings.ToLower(types.String(value)) == strings.ToLower(this.Value)
return strings.EqualFold(types.String(value), this.Value)
} else {
return types.String(value) == this.Value
}
case RuleOperatorNeqString:
if this.IsCaseInsensitive {
return strings.ToLower(types.String(value)) != strings.ToLower(this.Value)
return !strings.EqualFold(types.String(value), this.Value)
} else {
return types.String(value) != this.Value
}