Fix missing empty type and color values validation (#2510)

* Fix missing empty type and color values validation
pull/3545/head
Darko Draskovic 2024-08-14 16:41:11 +00:00 committed by Harness
parent c3c75d47aa
commit 7e3253d366
1 changed files with 11 additions and 2 deletions

View File

@ -264,8 +264,6 @@ func (in *SaveInput) Validate() error {
return nil
}
var labelTypes, _ = enum.GetAllLabelTypes()
func validateLabelText(text *string, typ string) error {
*text = strings.TrimSpace(*text)
@ -286,16 +284,27 @@ func validateLabelText(text *string, typ string) error {
return nil
}
var labelTypes, _ = enum.GetAllLabelTypes()
func validateLabelType(typ enum.LabelType) error {
if typ == "" {
return errors.InvalidArgument("label type missing")
}
if _, ok := typ.Sanitize(); !ok {
return errors.InvalidArgument("label type must be in %v", labelTypes)
}
return nil
}
var colorTypes, _ = enum.GetAllLabelColors()
func validateLabelColor(color enum.LabelColor) error {
if color == "" {
return errors.InvalidArgument("label color missing")
}
_, ok := color.Sanitize()
if !ok {
return errors.InvalidArgument("color type must be in %v", colorTypes)