We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 656e6ce commit 56667d7Copy full SHA for 56667d7
1 file changed
validator/validator.go
@@ -32,6 +32,10 @@ func (v *Validator) Valid() bool {
32
// AddError records a validation error for a field
33
// Existing errors for the same field are preserved (no overwrite)
34
func (v *Validator) AddError(key, message string) {
35
+ if v.Errors == nil {
36
+ v.Errors = make(map[string]string)
37
+ }
38
+
39
if _, exists := v.Errors[key]; !exists {
40
v.Errors[key] = message
41
}
@@ -69,7 +73,6 @@ func Unique[T comparable](values []T) bool {
69
73
return len(values) == len(uniqueValues)
70
74
71
75
72
-
76
// NotBlank returns true if value contains non-whitespace characters
77
func NotBlank(value string) bool {
78
return strings.TrimSpace(value) != ""
0 commit comments