@@ -74,22 +74,23 @@ func (g *DefaultValidator) ValidateExperiment(instance, oldInst *experimentsv1be
7474 return fmt .Errorf (msg )
7575 }
7676
77- if instance .Spec .MaxFailedTrialCount != nil {
78- if * instance .Spec .MaxFailedTrialCount < 0 {
79- return fmt .Errorf ("spec.maxFailedTrialCount should not be less than 0" )
80- }
81- if instance .Spec .MaxTrialCount != nil && * instance .Spec .MaxFailedTrialCount > * instance .Spec .MaxTrialCount {
82- return fmt .Errorf ("spec.maxFailedTrialCount should be less than or equal to spec.maxTrialCount" )
83- }
77+ if instance .Spec .MaxFailedTrialCount != nil && * instance .Spec .MaxFailedTrialCount < 0 {
78+ return fmt .Errorf ("spec.maxFailedTrialCount should not be less than 0" )
8479 }
8580 if instance .Spec .MaxTrialCount != nil && * instance .Spec .MaxTrialCount <= 0 {
8681 return fmt .Errorf ("spec.maxTrialCount must be greater than 0" )
8782 }
88- if instance .Spec .ParallelTrialCount != nil {
89- if * instance .Spec .ParallelTrialCount <= 0 {
90- return fmt .Errorf ("spec.parallelTrialCount must be greater than 0" )
83+ if instance .Spec .ParallelTrialCount != nil && * instance .Spec .ParallelTrialCount <= 0 {
84+ return fmt .Errorf ("spec.parallelTrialCount must be greater than 0" )
85+ }
86+
87+ if instance .Spec .MaxFailedTrialCount != nil && instance .Spec .MaxTrialCount != nil {
88+ if * instance .Spec .MaxFailedTrialCount > * instance .Spec .MaxTrialCount {
89+ return fmt .Errorf ("spec.maxFailedTrialCount should be less than or equal to spec.maxTrialCount" )
9190 }
92- if instance .Spec .MaxTrialCount != nil && * instance .Spec .ParallelTrialCount > * instance .Spec .MaxTrialCount {
91+ }
92+ if instance .Spec .ParallelTrialCount != nil && instance .Spec .MaxTrialCount != nil {
93+ if * instance .Spec .ParallelTrialCount > * instance .Spec .MaxTrialCount {
9394 return fmt .Errorf ("spec.paralelTrialCount should be less than or equal to spec.maxTrialCount" )
9495 }
9596 }
0 commit comments