Skip to content

Commit

Permalink
Removed "required" tag from failOnValidationErrors
Browse files Browse the repository at this point in the history
Signed-off-by: Venera <[email protected]>
  • Loading branch information
venera-program committed Oct 3, 2023
1 parent f50885c commit 91c3fa6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion model/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions model/workflow_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 91c3fa6

Please sign in to comment.