github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/network/validator/any_validator.go (about) 1 package validator 2 3 import ( 4 "github.com/onflow/flow-go/network" 5 ) 6 7 var _ network.MessageValidator = (*AnyValidator)(nil) 8 9 // AnyValidator returns true if any of the given validators returns true 10 type AnyValidator struct { 11 validators []network.MessageValidator 12 } 13 14 func NewAnyValidator(validators ...network.MessageValidator) network.MessageValidator { 15 return &AnyValidator{ 16 validators: validators, 17 } 18 } 19 20 func (v AnyValidator) Validate(msg network.IncomingMessageScope) bool { 21 for _, validator := range v.validators { 22 if validator.Validate(msg) { 23 return true 24 } 25 } 26 return false 27 }