forked from go-toolset/pepperlint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rule_interface_type.go
32 lines (26 loc) · 839 Bytes
/
rule_interface_type.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package pepperlint
import (
"go/ast"
)
// InterfaceTypeRules is a list of type InterfaceTypeRule.
type InterfaceTypeRules []InterfaceTypeRule
// ValidateInterfaceType will iterate through the list of array types and call
// ValidateInterfaceType. If an error is returned, then that error will be added
// to the batch of errors.
func (rules InterfaceTypeRules) ValidateInterfaceType(iface *ast.InterfaceType) error {
batchError := NewBatchError()
for _, rule := range rules {
if err := rule.ValidateInterfaceType(iface); err != nil {
batchError.Add(err)
}
}
if batchError.Len() == 0 {
return nil
}
return batchError
}
// InterfaceTypeRule represents an interface that will allow for validation
// to occur on an ast.InterfaceType.
type InterfaceTypeRule interface {
ValidateInterfaceType(*ast.InterfaceType) error
}