github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/network/validator/not_validator.go (about)

     1  package validator
     2  
     3  import (
     4  	"github.com/onflow/flow-go/network"
     5  )
     6  
     7  var _ network.MessageValidator = (*NotValidator)(nil)
     8  
     9  // NotValidator returns the opposite result of the given validator for the Validate call
    10  type NotValidator struct {
    11  	validator network.MessageValidator
    12  }
    13  
    14  func NewNotValidator(validator network.MessageValidator) network.MessageValidator {
    15  	return &NotValidator{
    16  		validator: validator,
    17  	}
    18  }
    19  
    20  func (n NotValidator) Validate(msg network.IncomingMessageScope) bool {
    21  	return !n.validator.Validate(msg)
    22  }