mirror of
https://github.com/harness/drone.git
synced 2025-05-31 11:43:15 +00:00
Fix missing empty type and color values validation (#2510)
* Fix missing empty type and color values validation
This commit is contained in:
parent
c3c75d47aa
commit
7e3253d366
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user