mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-01 05:01:47 +02:00
internal refactoring
This commit is contained in:
parent
6c7cff4f16
commit
4b2802a6ba
2 changed files with 27 additions and 4 deletions
|
@ -25,7 +25,7 @@ func IsValid(v Validateable) (bool, error) {
|
|||
return true, nil
|
||||
}
|
||||
|
||||
func ValidateNotEmpty(value any, fieldName string) []string {
|
||||
func ValidateNotEmpty(value any, name string) []string {
|
||||
isValid := true
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
|
@ -47,12 +47,12 @@ func ValidateNotEmpty(value any, fieldName string) []string {
|
|||
if isValid {
|
||||
return []string{}
|
||||
}
|
||||
return []string{fmt.Sprintf("Field %v should not be empty", fieldName)}
|
||||
return []string{fmt.Sprintf("%v should not be empty", name)}
|
||||
}
|
||||
|
||||
func ValidateMaxLen(value string, maxLen int, fieldName string) []string {
|
||||
func ValidateMaxLen(value string, maxLen int, name string) []string {
|
||||
if utf8.RuneCountInString(value) > maxLen {
|
||||
return []string{fmt.Sprintf("Value in field %v was longer than %v", fieldName, maxLen)}
|
||||
return []string{fmt.Sprintf("Value %v was longer than %v", name, maxLen)}
|
||||
}
|
||||
return []string{}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue