Skip to content

Commit 0c36ccb

Browse files
committed
chore: extract function
1 parent 7d4b5b6 commit 0c36ccb

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

internal/storage/common/resource.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,7 @@ func (r *ResourceRepository[ResourceType, OptionsType]) validateFilters(builder
105105
if property.Type.IsIndexable() {
106106
key = strings.Split(key, "[")[0]
107107
}
108-
match := func() bool {
109-
if key == name {
110-
return true
111-
}
112-
for _, alias := range property.Aliases {
113-
if key == alias {
114-
return true
115-
}
116-
}
117-
118-
return false
119-
}()
120-
if !match {
108+
if !property.matchKey(name, key) {
121109
continue
122110
}
123111

@@ -445,6 +433,19 @@ func (f Field) WithAliases(aliases ...string) Field {
445433
return f
446434
}
447435

436+
func (f Field) matchKey(name, key string) bool {
437+
if key == name {
438+
return true
439+
}
440+
for _, alias := range f.Aliases {
441+
if key == alias {
442+
return true
443+
}
444+
}
445+
446+
return false
447+
}
448+
448449
func NewField(t FieldType) Field {
449450
return Field{
450451
Aliases: []string{},

0 commit comments

Comments
 (0)