...

Source file src/github.com/grpc-ecosystem/go-grpc-middleware/testing/testproto/test.manual_validator.pb.go

Documentation: github.com/grpc-ecosystem/go-grpc-middleware/testing/testproto

     1  // Manual code for validation tests.
     2  
     3  package mwitkow_testproto
     4  
     5  import (
     6  	"errors"
     7  	"math"
     8  )
     9  
    10  // Implements the legacy validation interface from protoc-gen-validate.
    11  func (p *PingRequest) Validate() error {
    12  	if p.SleepTimeMs > 10000 {
    13  		return errors.New("cannot sleep for more than 10s")
    14  	}
    15  	return nil
    16  }
    17  
    18  // Implements the new validation interface from protoc-gen-validate.
    19  func (p *PingResponse) Validate(bool) error {
    20  	if p.Counter > math.MaxInt16 {
    21  		return errors.New("ping allocation exceeded")
    22  	}
    23  	return nil
    24  }
    25  

View as plain text