// Validate tests whether the stream name is valid.
511224
func (s StreamName) Validate() error {
	if len(s) == 0 {
		return errors.New("must contain at least one character")
	}
	if len(s) > MaxStreamNameLength {
		return fmt.Errorf("stream name is too long (%d > %d)", len(s), MaxStreamNameLength)
	}

	var lastRune rune
	var segmentIdx int
	for idx, r := range s {
		// Alphanumeric.
		if !isAlnum(r) {
			// The stream name must begin with an alphanumeric character.
			if idx == segmentIdx {
				return fmt.Errorf("Segment (at %d) must begin with alphanumeric character.", segmentIdx)
			}

			// Test forward slash, and ensure no adjacent forward slashes.
			if r == StreamNameSep {
				segmentIdx = idx + utf8.RuneLen(r)
			} else if !(r == '.' || r == '_' || r == '-' || r == ':') {
				// Test remaining allowed characters.
				return fmt.Errorf("Illegal charater (%c) at index %d.", r, idx)
			}
		}
		lastRune = r
	}

	// The last rune may not be a separator.
	if lastRune == StreamNameSep {
		return errors.New("Name may not end with a separator.")
	}
	return nil
}
38239
func (v *FilterType) Validate() error {

	if v.Prefix == nil {
		return errors.ParameterRequiredError{
			ParameterName: "Prefix",
			ParentName:    "Filter",
		}
	}

	return nil
}
173920
func (c Channel) Validate() error {
	if c.Title == "" {
		return errors.New(ErrValidation, errorMessages, "channel title must not be empty")
	}
	if c.Description == "" {
		return errors.New(ErrValidation, errorMessages, "channel description must not be empty")
	}
	if c.Link == "" {
		return errors.New(ErrValidation, errorMessages, "channel link must not be empty")
	}
	if _, err := url.Parse(c.Link); err != nil {
		return errors.Annotate(err, ErrParsing, errorMessages, "channel link")
	}
	for _, category := range c.Categories {
		if err := category.Validate(); err != nil {
			return err
		}
	}
	if c.Cloud != nil {
		if err := c.Cloud.Validate(); err != nil {
			return err
		}
	}
	if c.Docs != "" && c.Docs != "http://blogs.law.harvard.edu/tech/rss" {
		return errors.New(ErrValidation, errorMessages, "docs %q is not valid", c.Docs)
	}
	if c.Image != nil {
		if err := c.Image.Validate(); err != nil {
			return err
		}
	}
	if c.Language != "" {
		// TODO(mue) Language has to be validated.
	}
	if c.LastBuildDate != "" {
		if _, err := ParseTime(c.LastBuildDate); err != nil {
			return errors.Annotate(err, ErrParsing, errorMessages, "channel last build date")
		}
	}
	if c.PubDate != "" {
		if _, err := ParseTime(c.PubDate); err != nil {
			return errors.Annotate(err, ErrParsing, errorMessages, "channel publication date")
		}
	}
	if c.SkipDays != nil {
		if err := c.SkipDays.Validate(); err != nil {
			return err
		}
	}
	if c.SkipHours != nil {
		if err := c.SkipHours.Validate(); err != nil {
			return err
		}
	}
	if c.TTL < 0 {
		return errors.New(ErrValidation, errorMessages, "channel ttl is below zero")
	}
	for _, item := range c.Items {
		if err := item.Validate(); err != nil {
			return err
		}
	}
	return nil
}
1210215
func (self *ResourceOutput) Validate() error {
	if self.Name == "" {
		return fmt.Errorf("ResourceOutput.name is missing but is a required field")
	} else {
		val := Validate(RdlSchema(), "Identifier", self.Name)
		if !val.Valid {
			return fmt.Errorf("ResourceOutput.name does not contain a valid Identifier (%v)", val.Error)
		}
	}
	if self.Type == "" {
		return fmt.Errorf("ResourceOutput.type is missing but is a required field")
	} else {
		val := Validate(RdlSchema(), "TypeRef", self.Type)
		if !val.Valid {
			return fmt.Errorf("ResourceOutput.type does not contain a valid TypeRef (%v)", val.Error)
		}
	}
	if self.Header == "" {
		return fmt.Errorf("ResourceOutput.header is missing but is a required field")
	} else {
		val := Validate(RdlSchema(), "String", self.Header)
		if !val.Valid {
			return fmt.Errorf("ResourceOutput.header does not contain a valid String (%v)", val.Error)
		}
	}
	return nil
}
462193
func (m *OutputSink) Validate() error {
	if m == nil {
		return nil
	}

	if _, ok := OutputSink_Format_name[int32(m.GetFormat())]; !ok {
		return OutputSinkValidationError{
			field:  "Format",
			reason: "value must be one of the defined enum values",
		}
	}

	switch m.OutputSinkType.(type) {

	case *OutputSink_StreamingAdmin:

		{
			tmp := m.GetStreamingAdmin()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return OutputSinkValidationError{
						field:  "StreamingAdmin",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	case *OutputSink_FilePerTap:

		{
			tmp := m.GetFilePerTap()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return OutputSinkValidationError{
						field:  "FilePerTap",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	default:
		return OutputSinkValidationError{
			field:  "OutputSinkType",
			reason: "value is required",
		}

	}

	return nil
}
227017
func (s *StreamAddr) Validate() error {
	if s.Host == "" {
		return errors.New("cannot have empty Host")
	}
	if err := s.Project.Validate(); err != nil {
		return err
	}
	if err := s.Path.Validate(); err != nil {
		return err
	}
	return nil
}
1236866
func (as AnnotationSeries) Validate() error {
	if len(as.Annotations) == 0 {
		return fmt.Errorf("annotation series requires annotations to be set and not empty")
	}
	return nil
}
1016848
func (key AnnotationKey) Validate(_ interface{}) error {
	if annotationKeyRegex.Match([]byte(key)) {
		return nil
	}

	return errInvalidAnnotationKey
}
243540
func (m *GenericError) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateName(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
426190
func (m *FilterStateRule) Validate() error {
	if m == nil {
		return nil
	}

	if len(m.GetName()) < 1 {
		return FilterStateRuleValidationError{
			field:  "Name",
			reason: "value length must be at least 1 bytes",
		}
	}

	// no validation rules for Requires

	return nil
}
1251695
func (m *HttpStreamedTraceSegment) Validate() error {
	if m == nil {
		return nil
	}

	// no validation rules for TraceId

	switch m.MessagePiece.(type) {

	case *HttpStreamedTraceSegment_RequestHeaders:

		{
			tmp := m.GetRequestHeaders()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return HttpStreamedTraceSegmentValidationError{
						field:  "RequestHeaders",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	case *HttpStreamedTraceSegment_RequestBodyChunk:

		{
			tmp := m.GetRequestBodyChunk()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return HttpStreamedTraceSegmentValidationError{
						field:  "RequestBodyChunk",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	case *HttpStreamedTraceSegment_RequestTrailers:

		{
			tmp := m.GetRequestTrailers()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return HttpStreamedTraceSegmentValidationError{
						field:  "RequestTrailers",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	case *HttpStreamedTraceSegment_ResponseHeaders:

		{
			tmp := m.GetResponseHeaders()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return HttpStreamedTraceSegmentValidationError{
						field:  "ResponseHeaders",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	case *HttpStreamedTraceSegment_ResponseBodyChunk:

		{
			tmp := m.GetResponseBodyChunk()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return HttpStreamedTraceSegmentValidationError{
						field:  "ResponseBodyChunk",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	case *HttpStreamedTraceSegment_ResponseTrailers:

		{
			tmp := m.GetResponseTrailers()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return HttpStreamedTraceSegmentValidationError{
						field:  "ResponseTrailers",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	}

	return nil
}
116491
func (g MayuFlags) Validate() (bool, error) {
	if ok, err := g.ValidateHTTPCertificateUsage(); !ok {
		return ok, err
	}

	if ok, err := g.ValidateHTTPCertificateFileExistance(); !ok {
		return ok, err
	}

	return true, nil
}
781787
func (policy Policy) Validate(bucketName string) error {
	if err := policy.isValid(); err != nil {
		return err
	}

	for _, statement := range policy.Statements {
		if err := statement.Validate(bucketName); err != nil {
			return err
		}
	}

	return nil
}
1168045
func (s *XPackWatcherPutWatchService) Validate() error {
	var invalid []string
	if s.id == "" {
		invalid = append(invalid, "Id")
	}
	if s.body == nil {
		invalid = append(invalid, "Body")
	}
	if len(invalid) > 0 {
		return fmt.Errorf("missing required fields: %v", invalid)
	}
	return nil
}
45450
func (s *IndicesShrinkService) Validate() error {
	var invalid []string
	if s.source == "" {
		invalid = append(invalid, "Source")
	}
	if s.target == "" {
		invalid = append(invalid, "Target")
	}
	if len(invalid) > 0 {
		return fmt.Errorf("missing required fields: %v", invalid)
	}
	return nil
}
176557
func (s *Service) validate() error {
	if s.Name == "" {
		return fmt.Errorf("Service lacks Name field: %v", s)
	}
	if s.Port < 1 || s.Port > 65535 {
		return fmt.Errorf("Service Port is outside valid range: %v", s)
	}

	return nil
}
6496
func (s HorizontalPodAutoscalerGeneratorV1) validate() error {
	if len(s.Name) == 0 {
		return fmt.Errorf("name must be specified")
	}
	if s.MaxReplicas < 1 {
		return fmt.Errorf("'max' is a required parameter and must be at least 1")
	}
	if s.MinReplicas > s.MaxReplicas {
		return fmt.Errorf("'max' must be greater than or equal to 'min'")
	}
	return nil
}