From 91c3fa6e7d16c27bbe0380449593d15d9e8bf0b6 Mon Sep 17 00:00:00 2001 From: Venera <31911811+venera-program@users.noreply.github.com> Date: Tue, 3 Oct 2023 12:38:12 -0700 Subject: [PATCH] Removed "required" tag from failOnValidationErrors Signed-off-by: Venera <31911811+venera-program@users.noreply.github.com> --- model/workflow.go | 2 +- model/workflow_validator_test.go | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/model/workflow.go b/model/workflow.go index 6b6ac9d..3fddfb8 100644 --- a/model/workflow.go +++ b/model/workflow.go @@ -507,7 +507,7 @@ type DataInputSchema struct { // +kubebuilder:validation:Required Schema string `json:"schema" validate:"required"` // +kubebuilder:validation:Required - FailOnValidationErrors bool `json:"failOnValidationErrors" validate:"required"` + FailOnValidationErrors bool `json:"failOnValidationErrors"` } type dataInputSchemaUnmarshal DataInputSchema diff --git a/model/workflow_validator_test.go b/model/workflow_validator_test.go index eff6154..9cdb77e 100644 --- a/model/workflow_validator_test.go +++ b/model/workflow_validator_test.go @@ -417,6 +417,39 @@ Key: 'Workflow.States[3].BaseState.Transition.NextState' Error:Field validation StructLevelValidationCtx(t, testCases) } +func TestDataInputSchemaStructLevelValidation(t *testing.T) { + baseWorkflow := buildWorkflow() + + operationState := buildOperationState(baseWorkflow, "start state") + buildEndByState(operationState, true, false) + action1 := buildActionByOperationState(operationState, "action 1") + buildFunctionRef(baseWorkflow, action1, "function 1") + + testCases := []ValidationCase{ + { + Desp: "empty DataInputSchema", + Model: func() Workflow { + model := baseWorkflow.DeepCopy() + model.DataInputSchema = &DataInputSchema{} + return *model + }, + Err: `workflow.dataInputSchema.schema is required`, + }, + { + Desp: "filled Schema, default failOnValidationErrors", + Model: func() Workflow { + model := baseWorkflow.DeepCopy() + model.DataInputSchema = &DataInputSchema{ + Schema: "sample schema", + } + return *model + }, + }, + } + + StructLevelValidationCtx(t, testCases) +} + func TestSecretsStructLevelValidation(t *testing.T) { baseWorkflow := buildWorkflow()