/internal/gen/proto/go/buf/module/v1/module.pb.validate.go
https://github.com/bufbuild/buf · Go · 287 lines · 175 code · 58 blank · 54 comment · 23 complexity · 321e2ccbde7b2488db361397a9b46092 MD5 · raw file
- // Copyright 2020 Buf Technologies, Inc.
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- // Code generated by protoc-gen-validate. DO NOT EDIT.
- // source: buf/module/v1/module.proto
- package modulev1
- import (
- "bytes"
- "errors"
- "fmt"
- "net"
- "net/mail"
- "net/url"
- "regexp"
- "strings"
- "time"
- "unicode/utf8"
- "github.com/golang/protobuf/ptypes"
- )
- // ensure the imports are used
- var (
- _ = bytes.MinRead
- _ = errors.New("")
- _ = fmt.Print
- _ = utf8.UTFMax
- _ = (*regexp.Regexp)(nil)
- _ = (*strings.Reader)(nil)
- _ = net.IPv4len
- _ = time.Duration(0)
- _ = (*url.URL)(nil)
- _ = (*mail.Address)(nil)
- _ = ptypes.DynamicAny{}
- )
- // define the regex for a UUID once up-front
- var _module_uuidPattern = regexp.MustCompile("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$")
- // Validate checks the field values on Module with the rules defined in the
- // proto definition for this message. If any rules are violated, an error is returned.
- func (m *Module) Validate() error {
- if m == nil {
- return nil
- }
- for idx, item := range m.GetFiles() {
- _, _ = idx, item
- if v, ok := interface{}(item).(interface{ Validate() error }); ok {
- if err := v.Validate(); err != nil {
- return ModuleValidationError{
- field: fmt.Sprintf("Files[%v]", idx),
- reason: "embedded message failed validation",
- cause: err,
- }
- }
- }
- }
- for idx, item := range m.GetDependencies() {
- _, _ = idx, item
- if v, ok := interface{}(item).(interface{ Validate() error }); ok {
- if err := v.Validate(); err != nil {
- return ModuleValidationError{
- field: fmt.Sprintf("Dependencies[%v]", idx),
- reason: "embedded message failed validation",
- cause: err,
- }
- }
- }
- }
- return nil
- }
- // ModuleValidationError is the validation error returned by Module.Validate if
- // the designated constraints aren't met.
- type ModuleValidationError struct {
- field string
- reason string
- cause error
- key bool
- }
- // Field function returns field value.
- func (e ModuleValidationError) Field() string { return e.field }
- // Reason function returns reason value.
- func (e ModuleValidationError) Reason() string { return e.reason }
- // Cause function returns cause value.
- func (e ModuleValidationError) Cause() error { return e.cause }
- // Key function returns key value.
- func (e ModuleValidationError) Key() bool { return e.key }
- // ErrorName returns error name.
- func (e ModuleValidationError) ErrorName() string { return "ModuleValidationError" }
- // Error satisfies the builtin error interface
- func (e ModuleValidationError) Error() string {
- cause := ""
- if e.cause != nil {
- cause = fmt.Sprintf(" | caused by: %v", e.cause)
- }
- key := ""
- if e.key {
- key = "key for "
- }
- return fmt.Sprintf(
- "invalid %sModule.%s: %s%s",
- key,
- e.field,
- e.reason,
- cause)
- }
- var _ error = ModuleValidationError{}
- var _ interface {
- Field() string
- Reason() string
- Key() bool
- Cause() error
- ErrorName() string
- } = ModuleValidationError{}
- // Validate checks the field values on ModuleFile with the rules defined in the
- // proto definition for this message. If any rules are violated, an error is returned.
- func (m *ModuleFile) Validate() error {
- if m == nil {
- return nil
- }
- // no validation rules for Path
- // no validation rules for Content
- return nil
- }
- // ModuleFileValidationError is the validation error returned by
- // ModuleFile.Validate if the designated constraints aren't met.
- type ModuleFileValidationError struct {
- field string
- reason string
- cause error
- key bool
- }
- // Field function returns field value.
- func (e ModuleFileValidationError) Field() string { return e.field }
- // Reason function returns reason value.
- func (e ModuleFileValidationError) Reason() string { return e.reason }
- // Cause function returns cause value.
- func (e ModuleFileValidationError) Cause() error { return e.cause }
- // Key function returns key value.
- func (e ModuleFileValidationError) Key() bool { return e.key }
- // ErrorName returns error name.
- func (e ModuleFileValidationError) ErrorName() string { return "ModuleFileValidationError" }
- // Error satisfies the builtin error interface
- func (e ModuleFileValidationError) Error() string {
- cause := ""
- if e.cause != nil {
- cause = fmt.Sprintf(" | caused by: %v", e.cause)
- }
- key := ""
- if e.key {
- key = "key for "
- }
- return fmt.Sprintf(
- "invalid %sModuleFile.%s: %s%s",
- key,
- e.field,
- e.reason,
- cause)
- }
- var _ error = ModuleFileValidationError{}
- var _ interface {
- Field() string
- Reason() string
- Key() bool
- Cause() error
- ErrorName() string
- } = ModuleFileValidationError{}
- // Validate checks the field values on ModuleName with the rules defined in the
- // proto definition for this message. If any rules are violated, an error is returned.
- func (m *ModuleName) Validate() error {
- if m == nil {
- return nil
- }
- // no validation rules for Remote
- // no validation rules for Owner
- // no validation rules for Repository
- // no validation rules for Version
- // no validation rules for Digest
- return nil
- }
- // ModuleNameValidationError is the validation error returned by
- // ModuleName.Validate if the designated constraints aren't met.
- type ModuleNameValidationError struct {
- field string
- reason string
- cause error
- key bool
- }
- // Field function returns field value.
- func (e ModuleNameValidationError) Field() string { return e.field }
- // Reason function returns reason value.
- func (e ModuleNameValidationError) Reason() string { return e.reason }
- // Cause function returns cause value.
- func (e ModuleNameValidationError) Cause() error { return e.cause }
- // Key function returns key value.
- func (e ModuleNameValidationError) Key() bool { return e.key }
- // ErrorName returns error name.
- func (e ModuleNameValidationError) ErrorName() string { return "ModuleNameValidationError" }
- // Error satisfies the builtin error interface
- func (e ModuleNameValidationError) Error() string {
- cause := ""
- if e.cause != nil {
- cause = fmt.Sprintf(" | caused by: %v", e.cause)
- }
- key := ""
- if e.key {
- key = "key for "
- }
- return fmt.Sprintf(
- "invalid %sModuleName.%s: %s%s",
- key,
- e.field,
- e.reason,
- cause)
- }
- var _ error = ModuleNameValidationError{}
- var _ interface {
- Field() string
- Reason() string
- Key() bool
- Cause() error
- ErrorName() string
- } = ModuleNameValidationError{}