Insensitive case for allow-empty value.
This commit is contained in:
parent
2e20394af4
commit
ee0e014617
2 changed files with 28 additions and 1 deletions
|
@ -52,7 +52,7 @@ func addMetadata(rootType reflect.Type, node *Node) error {
|
||||||
return fmt.Errorf("node %s (type %s) must have children", node.Name, fType)
|
return fmt.Errorf("node %s (type %s) must have children", node.Name, fType)
|
||||||
}
|
}
|
||||||
|
|
||||||
node.Disabled = len(node.Value) > 0 && node.Value != "true" && field.Tag.Get(TagLabel) == "allowEmpty"
|
node.Disabled = len(node.Value) > 0 && !strings.EqualFold(node.Value, "true") && field.Tag.Get(TagLabel) == "allowEmpty"
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(node.Children) == 0 {
|
if len(node.Children) == 0 {
|
||||||
|
|
|
@ -451,6 +451,33 @@ func TestAddMetadata(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
desc: "level 2, struct with allowEmpty, value true with case variation",
|
||||||
|
tree: &Node{
|
||||||
|
Name: "traefik",
|
||||||
|
Children: []*Node{
|
||||||
|
{Name: "Foo", Value: "TruE"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
structure: struct {
|
||||||
|
Foo struct {
|
||||||
|
Bar string
|
||||||
|
} `label:"allowEmpty"`
|
||||||
|
}{
|
||||||
|
Foo: struct {
|
||||||
|
Bar string
|
||||||
|
}{},
|
||||||
|
},
|
||||||
|
expected: expected{
|
||||||
|
node: &Node{
|
||||||
|
Name: "traefik",
|
||||||
|
Kind: reflect.Struct,
|
||||||
|
Children: []*Node{
|
||||||
|
{Name: "Foo", FieldName: "Foo", Value: "TruE", Kind: reflect.Struct},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
desc: "level 2, struct with allowEmpty, value false",
|
desc: "level 2, struct with allowEmpty, value false",
|
||||||
tree: &Node{
|
tree: &Node{
|
||||||
|
|
Loading…
Add table
Reference in a new issue