Created
November 19, 2024 17:11
-
-
Save jclem/9fdd16fb5d2d8e610e0a6f3fd1eb28a0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (c Collection) Validate() error { | |
v := vld.New() | |
strlen := vld.StrLen(1, 64) | |
v.Validate( | |
[]string{"name"}, | |
strlen(c.Name), | |
) | |
v.Validate( | |
[]string{"tags", "key"}, | |
vld.MapKeys[string, string](strlen)(c.Tags), | |
) | |
v.Validate( | |
[]string{"tags", "value"}, | |
vld.MapValues[string](strlen)(c.Tags), | |
) | |
if err := v.GetError(); err != nil { | |
return fmt.Errorf("validate collection: %w", err) | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment