From 48866d60fea3e20cb7a0efa8807a55785ac79ad8 Mon Sep 17 00:00:00 2001 From: Marvin Wendt Date: Fri, 9 Feb 2024 14:28:07 +0100 Subject: [PATCH] feat: added multiline validation --- pkg/model/model.go | 7 +++++++ testdata/must-fail/number/multiline-number.yml | 6 ++++++ 2 files changed, 13 insertions(+) create mode 100644 testdata/must-fail/number/multiline-number.yml diff --git a/pkg/model/model.go b/pkg/model/model.go index 8ece720..9c969ab 100644 --- a/pkg/model/model.go +++ b/pkg/model/model.go @@ -129,6 +129,13 @@ func (v Variable) Validate() []error { } } + // Multiline is only applicable to text types + if v.Multiline { + if v.Type != "text" { + errors = append(errors, newValidationError(v, "multiline is only applicable to text types")) + } + } + // Options are only applicable to select and multiselect types if len(v.Options) > 0 { if v.Type != "select" && v.Type != "multiselect" { diff --git a/testdata/must-fail/number/multiline-number.yml b/testdata/must-fail/number/multiline-number.yml new file mode 100644 index 0000000..506abd9 --- /dev/null +++ b/testdata/must-fail/number/multiline-number.yml @@ -0,0 +1,6 @@ +# yaml-language-server: $schema=https://gttp.dev/schema +variables: + - name: Number + type: number + multiline: true +template: "{{ .Number }}"