1
0
Fork 0

Merging upstream version 1.0.1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-26 05:48:23 +02:00
parent c8b00cb8af
commit 61133985ce
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
13 changed files with 86 additions and 43 deletions

View file

@ -464,22 +464,22 @@ VALIDATE_RULES:
break VALIDATE_RULES
}
case strings.HasPrefix(rule, "MinSize("):
min, _ := strconv.Atoi(rule[8 : len(rule)-1])
if str, ok := fieldValue.(string); ok && utf8.RuneCountInString(str) < min {
minSize, _ := strconv.Atoi(rule[8 : len(rule)-1])
if str, ok := fieldValue.(string); ok && utf8.RuneCountInString(str) < minSize {
errors.Add([]string{field.Name}, ERR_MIN_SIZE, "MinSize")
break VALIDATE_RULES
}
if fieldVal.Kind() == reflect.Slice && fieldVal.Len() < min {
if fieldVal.Kind() == reflect.Slice && fieldVal.Len() < minSize {
errors.Add([]string{field.Name}, ERR_MIN_SIZE, "MinSize")
break VALIDATE_RULES
}
case strings.HasPrefix(rule, "MaxSize("):
max, _ := strconv.Atoi(rule[8 : len(rule)-1])
if str, ok := fieldValue.(string); ok && utf8.RuneCountInString(str) > max {
maxSize, _ := strconv.Atoi(rule[8 : len(rule)-1])
if str, ok := fieldValue.(string); ok && utf8.RuneCountInString(str) > maxSize {
errors.Add([]string{field.Name}, ERR_MAX_SIZE, "MaxSize")
break VALIDATE_RULES
}
if fieldVal.Kind() == reflect.Slice && fieldVal.Len() > max {
if fieldVal.Kind() == reflect.Slice && fieldVal.Len() > maxSize {
errors.Add([]string{field.Name}, ERR_MAX_SIZE, "MaxSize")
break VALIDATE_RULES
}