validate empty text labels
This commit is contained in:
parent
731a7df195
commit
75ad59838b
2 changed files with 14 additions and 6 deletions
|
|
@ -1001,11 +1001,16 @@ func (c *compiler) validateKey(obj *d2graph.Object, f *d2ir.Field) {
|
||||||
|
|
||||||
func (c *compiler) validateLabels(g *d2graph.Graph) {
|
func (c *compiler) validateLabels(g *d2graph.Graph) {
|
||||||
for _, obj := range g.Objects {
|
for _, obj := range g.Objects {
|
||||||
if obj.Shape.Value == d2target.ShapeText {
|
if obj.Shape.Value != d2target.ShapeText {
|
||||||
if strings.TrimSpace(obj.Label.Value) == "" {
|
continue
|
||||||
c.errorf(obj.Label.MapKey, "text must have a label")
|
}
|
||||||
continue
|
if obj.Attributes.Language != "" {
|
||||||
}
|
// blockstrings have already been validated
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if strings.TrimSpace(obj.Label.Value) == "" {
|
||||||
|
c.errorf(obj.Label.MapKey, "shape text must have a non-empty label")
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2720,7 +2720,6 @@ object: {
|
||||||
b: " \n " {
|
b: " \n " {
|
||||||
shape: text
|
shape: text
|
||||||
}
|
}
|
||||||
|
|
||||||
c: "" {
|
c: "" {
|
||||||
shape: text
|
shape: text
|
||||||
}
|
}
|
||||||
|
|
@ -2728,6 +2727,10 @@ d: "" {
|
||||||
shape: circle
|
shape: circle
|
||||||
}
|
}
|
||||||
e: " \n "
|
e: " \n "
|
||||||
|
f: |md |
|
||||||
|
g: |md
|
||||||
|
|
||||||
|
|
|
||||||
`,
|
`,
|
||||||
expErr: `
|
expErr: `
|
||||||
`,
|
`,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue