-
Hi everyone, foo:
special_key:
- abcd This is my spectral ruleset special_key_missing:
description:
Special Key missing
severity: error
given: "$[*]"
then:
field: special_key
function: truthy This works fine and shows error when key is missing but the problem is error is shown in all lines. [![enter image description here][1]][1] How can I show the error at a specific line suppose in this case I want to show it at topmost level at |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey! I have a feeling the VS Code extension could be slightly adjusted to provide such a possibility, but there's not much you can do from the Spectral point of view. |
Beta Was this translation helpful? Give feedback.
Hey!
I'm afraid you cannot do that.
Spectral outputs the range of values that are invalid, and there's no way to point it at a particular line specifically, as it'll always refer to the invalid value.
In your case, the error is actually not shown for all lines, but it's the value of
foo
property that's highlighted.Note how that red-ish
~
starts right after:
and not at the beginning.I have a feeling the VS Code extension could be slightly adjusted to provide such a possibility, but there's not much you can do from the Spectral point of view.
It appears to me that it uses the aforementioned ranges which lead to the behavior you experience.
If it ignored the end boundary of the range, we'…