mirror of
https://github.com/chai2010/advanced-go-programming-book.git
synced 2025-05-24 20:47:11 +00:00
41 lines
1.2 KiB
Go
41 lines
1.2 KiB
Go
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
|
// source: helloworld.proto
|
|
|
|
/*
|
|
Package main is a generated protocol buffer package.
|
|
|
|
It is generated from these files:
|
|
helloworld.proto
|
|
|
|
It has these top-level messages:
|
|
Message
|
|
*/
|
|
package main
|
|
|
|
import regexp "regexp"
|
|
import fmt "fmt"
|
|
import go_proto_validators "github.com/mwitkow/go-proto-validators"
|
|
import proto "github.com/golang/protobuf/proto"
|
|
import math "math"
|
|
import _ "github.com/mwitkow/go-proto-validators"
|
|
|
|
// Reference imports to suppress errors if they are not otherwise used.
|
|
var _ = proto.Marshal
|
|
var _ = fmt.Errorf
|
|
var _ = math.Inf
|
|
|
|
var _regex_Message_ImportantString = regexp.MustCompile("^[a-z]{2,5}$")
|
|
|
|
func (this *Message) Validate() error {
|
|
if !_regex_Message_ImportantString.MatchString(this.ImportantString) {
|
|
return go_proto_validators.FieldError("ImportantString", fmt.Errorf(`value '%v' must be a string conforming to regex "^[a-z]{2,5}$"`, this.ImportantString))
|
|
}
|
|
if !(this.Age > 0) {
|
|
return go_proto_validators.FieldError("Age", fmt.Errorf(`value '%v' must be greater than '0'`, this.Age))
|
|
}
|
|
if !(this.Age < 100) {
|
|
return go_proto_validators.FieldError("Age", fmt.Errorf(`value '%v' must be less than '100'`, this.Age))
|
|
}
|
|
return nil
|
|
}
|