mirror of
https://github.com/rancher/norman.git
synced 2025-09-12 21:33:21 +00:00
don't validate empty string as DNS name
This commit is contained in:
@@ -259,14 +259,17 @@ func (b *Builder) convert(fieldType string, value interface{}, op Operation) (in
|
|||||||
case "string":
|
case "string":
|
||||||
return convert.ToString(value), nil
|
return convert.ToString(value), nil
|
||||||
case "dnsLabel":
|
case "dnsLabel":
|
||||||
value := convert.ToString(value)
|
str := convert.ToString(value)
|
||||||
|
if str == "" {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
if op == Create || op == Update {
|
if op == Create || op == Update {
|
||||||
if errs := validation.IsDNS1123Subdomain(convert.ToString(value)); len(errs) != 0 {
|
if errs := validation.IsDNS1123Subdomain(str); len(errs) != 0 {
|
||||||
return value, httperror.NewAPIError(httperror.InvalidFormat, fmt.Sprintf("invalid value %s: %s", value,
|
return value, httperror.NewAPIError(httperror.InvalidFormat, fmt.Sprintf("invalid value %s: %s", value,
|
||||||
strings.Join(errs, ",")))
|
strings.Join(errs, ",")))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value, nil
|
return str, nil
|
||||||
case "intOrString":
|
case "intOrString":
|
||||||
num, err := convert.ToNumber(value)
|
num, err := convert.ToNumber(value)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
Reference in New Issue
Block a user