Skip to content

Commit 56667d7

Browse files
committed
validator: fix nil map for v0.7.4
1 parent 656e6ce commit 56667d7

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

validator/validator.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ func (v *Validator) Valid() bool {
3232
// AddError records a validation error for a field
3333
// Existing errors for the same field are preserved (no overwrite)
3434
func (v *Validator) AddError(key, message string) {
35+
if v.Errors == nil {
36+
v.Errors = make(map[string]string)
37+
}
38+
3539
if _, exists := v.Errors[key]; !exists {
3640
v.Errors[key] = message
3741
}
@@ -69,7 +73,6 @@ func Unique[T comparable](values []T) bool {
6973
return len(values) == len(uniqueValues)
7074
}
7175

72-
7376
// NotBlank returns true if value contains non-whitespace characters
7477
func NotBlank(value string) bool {
7578
return strings.TrimSpace(value) != ""

0 commit comments

Comments
 (0)