refactor validation

This commit is contained in:
Michael Jerger 2024-05-01 15:02:27 +02:00
parent 4b2802a6ba
commit be6e6eb96a
4 changed files with 7 additions and 7 deletions

View file

@ -73,7 +73,7 @@ func (node NodeInfoWellKnown) Validate() []string {
result = append(result, "Href has to be absolute")
}
result = append(result, validation.ValidateOneOf(parsedURL.Scheme, []any{"http", "https"})...)
result = append(result, validation.ValidateOneOf(parsedURL.Scheme, []any{"http", "https"}, "parsedURL.Scheme")...)
if parsedURL.RawQuery != "" {
result = append(result, "Href may not contain query")
@ -129,7 +129,7 @@ func NewNodeInfo(body []byte) (NodeInfo, error) {
func (node NodeInfo) Validate() []string {
var result []string
result = append(result, validation.ValidateNotEmpty(string(node.SoftwareName), "source")...)
result = append(result, validation.ValidateOneOf(node.SoftwareName, KnownSourceTypes)...)
result = append(result, validation.ValidateOneOf(node.SoftwareName, KnownSourceTypes, "node.SoftwareName")...)
return result
}