@@ -74,11 +74,13 @@ func (av RequireIfAttributeIsOneOf) Validate(ctx context.Context, req RequireIfA
7474 return
7575 }
7676
77+ expression := req .PathExpression .Merge (av .PathExpression )
78+
7779 // Here attribute configuration is null or unknown, so we need to check if attribute in the path
7880 // is equal to one of the excepted values
79- paths , diags := req .Config .PathMatches (ctx , av . PathExpression )
81+ paths , diags := req .Config .PathMatches (ctx , expression )
8082 res .Diagnostics .Append (diags ... )
81- if diags .HasError () {
83+ if res . Diagnostics .HasError () {
8284 return
8385 }
8486
@@ -123,9 +125,10 @@ func (av RequireIfAttributeIsOneOf) Validate(ctx context.Context, req RequireIfA
123125
124126func (av RequireIfAttributeIsOneOf ) ValidateBool (ctx context.Context , req validator.BoolRequest , resp * validator.BoolResponse ) {
125127 validateReq := RequireIfAttributeIsOneOfRequest {
126- Config : req .Config ,
127- ConfigValue : req .ConfigValue ,
128- Path : req .Path ,
128+ Config : req .Config ,
129+ ConfigValue : req .ConfigValue ,
130+ Path : req .Path ,
131+ PathExpression : req .PathExpression ,
129132 }
130133 validateResp := & RequireIfAttributeIsOneOfResponse {}
131134
@@ -136,9 +139,10 @@ func (av RequireIfAttributeIsOneOf) ValidateBool(ctx context.Context, req valida
136139
137140func (av RequireIfAttributeIsOneOf ) ValidateFloat64 (ctx context.Context , req validator.Float64Request , resp * validator.Float64Response ) {
138141 validateReq := RequireIfAttributeIsOneOfRequest {
139- Config : req .Config ,
140- ConfigValue : req .ConfigValue ,
141- Path : req .Path ,
142+ Config : req .Config ,
143+ ConfigValue : req .ConfigValue ,
144+ Path : req .Path ,
145+ PathExpression : req .PathExpression ,
142146 }
143147 validateResp := & RequireIfAttributeIsOneOfResponse {}
144148
@@ -149,9 +153,10 @@ func (av RequireIfAttributeIsOneOf) ValidateFloat64(ctx context.Context, req val
149153
150154func (av RequireIfAttributeIsOneOf ) ValidateInt64 (ctx context.Context , req validator.Int64Request , resp * validator.Int64Response ) {
151155 validateReq := RequireIfAttributeIsOneOfRequest {
152- Config : req .Config ,
153- ConfigValue : req .ConfigValue ,
154- Path : req .Path ,
156+ Config : req .Config ,
157+ ConfigValue : req .ConfigValue ,
158+ Path : req .Path ,
159+ PathExpression : req .PathExpression ,
155160 }
156161 validateResp := & RequireIfAttributeIsOneOfResponse {}
157162
@@ -162,9 +167,10 @@ func (av RequireIfAttributeIsOneOf) ValidateInt64(ctx context.Context, req valid
162167
163168func (av RequireIfAttributeIsOneOf ) ValidateList (ctx context.Context , req validator.ListRequest , resp * validator.ListResponse ) {
164169 validateReq := RequireIfAttributeIsOneOfRequest {
165- Config : req .Config ,
166- ConfigValue : req .ConfigValue ,
167- Path : req .Path ,
170+ Config : req .Config ,
171+ ConfigValue : req .ConfigValue ,
172+ Path : req .Path ,
173+ PathExpression : req .PathExpression ,
168174 }
169175 validateResp := & RequireIfAttributeIsOneOfResponse {}
170176
@@ -175,9 +181,10 @@ func (av RequireIfAttributeIsOneOf) ValidateList(ctx context.Context, req valida
175181
176182func (av RequireIfAttributeIsOneOf ) ValidateMap (ctx context.Context , req validator.MapRequest , resp * validator.MapResponse ) {
177183 validateReq := RequireIfAttributeIsOneOfRequest {
178- Config : req .Config ,
179- ConfigValue : req .ConfigValue ,
180- Path : req .Path ,
184+ Config : req .Config ,
185+ ConfigValue : req .ConfigValue ,
186+ Path : req .Path ,
187+ PathExpression : req .PathExpression ,
181188 }
182189 validateResp := & RequireIfAttributeIsOneOfResponse {}
183190
@@ -188,9 +195,10 @@ func (av RequireIfAttributeIsOneOf) ValidateMap(ctx context.Context, req validat
188195
189196func (av RequireIfAttributeIsOneOf ) ValidateNumber (ctx context.Context , req validator.NumberRequest , resp * validator.NumberResponse ) {
190197 validateReq := RequireIfAttributeIsOneOfRequest {
191- Config : req .Config ,
192- ConfigValue : req .ConfigValue ,
193- Path : req .Path ,
198+ Config : req .Config ,
199+ ConfigValue : req .ConfigValue ,
200+ Path : req .Path ,
201+ PathExpression : req .PathExpression ,
194202 }
195203 validateResp := & RequireIfAttributeIsOneOfResponse {}
196204
@@ -201,9 +209,10 @@ func (av RequireIfAttributeIsOneOf) ValidateNumber(ctx context.Context, req vali
201209
202210func (av RequireIfAttributeIsOneOf ) ValidateObject (ctx context.Context , req validator.ObjectRequest , resp * validator.ObjectResponse ) {
203211 validateReq := RequireIfAttributeIsOneOfRequest {
204- Config : req .Config ,
205- ConfigValue : req .ConfigValue ,
206- Path : req .Path ,
212+ Config : req .Config ,
213+ ConfigValue : req .ConfigValue ,
214+ Path : req .Path ,
215+ PathExpression : req .PathExpression ,
207216 }
208217 validateResp := & RequireIfAttributeIsOneOfResponse {}
209218
@@ -214,9 +223,10 @@ func (av RequireIfAttributeIsOneOf) ValidateObject(ctx context.Context, req vali
214223
215224func (av RequireIfAttributeIsOneOf ) ValidateSet (ctx context.Context , req validator.SetRequest , resp * validator.SetResponse ) {
216225 validateReq := RequireIfAttributeIsOneOfRequest {
217- Config : req .Config ,
218- ConfigValue : req .ConfigValue ,
219- Path : req .Path ,
226+ Config : req .Config ,
227+ ConfigValue : req .ConfigValue ,
228+ Path : req .Path ,
229+ PathExpression : req .PathExpression ,
220230 }
221231 validateResp := & RequireIfAttributeIsOneOfResponse {}
222232
@@ -227,9 +237,10 @@ func (av RequireIfAttributeIsOneOf) ValidateSet(ctx context.Context, req validat
227237
228238func (av RequireIfAttributeIsOneOf ) ValidateString (ctx context.Context , req validator.StringRequest , resp * validator.StringResponse ) {
229239 validateReq := RequireIfAttributeIsOneOfRequest {
230- Config : req .Config ,
231- ConfigValue : req .ConfigValue ,
232- Path : req .Path ,
240+ Config : req .Config ,
241+ ConfigValue : req .ConfigValue ,
242+ Path : req .Path ,
243+ PathExpression : req .PathExpression ,
233244 }
234245 validateResp := & RequireIfAttributeIsOneOfResponse {}
235246
0 commit comments