// validate checks the marker bytes and version of the meta page to ensure it matches this binary.
184092
func (m *meta) validate() error {
	if m.magic != magic {
		return ErrInvalid
	} else if m.version != version {
		return ErrVersionMismatch
	} else if m.checksum != 0 && m.checksum != m.sum64() {
		return ErrChecksum
	}
	return nil
}
270121
func (e *LogEntry) Validate(d *LogStreamDescriptor) error {
	if e == nil {
		return errors.New("entry is nil")
	}

	// Check for content.
	switch d.StreamType {
	case StreamType_TEXT:
		if t := e.GetText(); t == nil || len(t.Lines) == 0 {
			return ErrNoContent
		}

	case StreamType_BINARY:
		if b := e.GetBinary(); b == nil || len(b.Data) == 0 {
			return ErrNoContent
		}

	case StreamType_DATAGRAM:
		if d := e.GetDatagram(); d == nil {
			return ErrNoContent
		}
	}
	return nil
}
1205967
func Validate(pattern string) (matcher *regexp.Regexp, err error) {
	pattern = strings.TrimSpace(pattern)
	pattern = strings.ToLower(pattern)

	// error check
	if strings.ContainsAny(pattern, "[]+{},") {
		return nil, errors.New(`Only alphanumeric ASCII characters, the hyphen "-", "." and "*" are allowed in a matchPattern`)
	}

	return regexp.Compile(ToRegexp(pattern))
}
665389
func (m *MetricBatch) validate() error {
	charmURL, err := charm.ParseURL(m.doc.CharmURL)
	if err != nil {
		return errors.Trace(err)
	}
	chrm, err := m.st.Charm(charmURL)
	if err != nil {
		return errors.Trace(err)
	}
	chrmMetrics := chrm.Metrics()
	if chrmMetrics == nil {
		return errors.Errorf("charm doesn't implement metrics")
	}
	for _, m := range m.doc.Metrics {
		if err := chrmMetrics.ValidateMetric(m.Key, m.Value); err != nil {
			return errors.Trace(err)
		}
	}
	return nil
}
614215
func (opts *Options) Validate() error {
	if _, found := opts.Tags[GUIDKey]; found {
		return errInvalidGUIDKey
	}

	if len(opts.Collector.CustomCACertFile) != 0 {
		if _, err := os.Stat(opts.Collector.CustomCACertFile); os.IsNotExist(err) {
			return err
		}
	}
	return nil
}
545844
func (p *Properties) Validate() error {
	if err := p.LogStreamDescriptor.Validate(false); err != nil {
		return err
	}
	return nil
}
1217156
func (d multiValidator) Validate(s interface{}) error {
	for _, validator := range d {
		if err := validator.Validate(s); err != nil {
			return err
		}
	}

	return nil
}
807763
func (pTypeDef *SymTest) Validate() error {
	if pTypeDef.Symmap == nil {
		return fmt.Errorf("SymTest: Missing required field: symmap")
	}
	if pTypeDef.Symary == nil {
		return fmt.Errorf("SymTest: Missing required field: symary")
	}
	if pTypeDef.Sym == "" {
		return fmt.Errorf("SymTest: Missing required field: sym")
	}
	return nil
}
1173056
func (m *Service) Validate(formats strfmt.Registry) error {
	var res []error

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

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

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
426747
func (g *GUID) Validate() error {
	if g.IsPermaLink {
		if _, err := url.Parse(g.GUID); err != nil {
			return errors.Annotate(err, ErrParsing, errorMessages, "item GUID")
		}
	}
	return nil
}
1189031
func (val AnnotationValue) Validate(_ interface{}) error {
	if annotationValueRegex.Match([]byte(val)) {
		return nil
	}

	return errInvalidAnnotationValue
}
728383
func (lbl Label) Validate(_ interface{}) error {
	if labelRegex.Match([]byte(lbl)) {
		return nil
	}

	return errInvalidLabel
}
1068284
func (m *BPFMap) Validate(formats strfmt.Registry) error {
	var res []error

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

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

	switch m.ParameterMatchSpecifier.(type) {

	case *MethodMatch_ParameterMatchSpecifier_ExactMatch:
		// no validation rules for ExactMatch

	case *MethodMatch_ParameterMatchSpecifier_RangeMatch:

		{
			tmp := m.GetRangeMatch()

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

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

	}

	return nil
}
1046598
func (m EndpointState) Validate(formats strfmt.Registry) error {
	var res []error

	// value enum
	if err := m.validateEndpointStateEnum("", "body", m); err != nil {
		return err
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
137511
func (m *Error) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
1003767
func (r *Route) Validate(skipZero bool) error {
	var res []error

	if !skipZero {
		if r.AppName == "" {
			res = append(res, ErrRoutesValidationMissingAppName)
		}

		if r.Image == "" {
			res = append(res, ErrRoutesValidationMissingImage)
		}

		if r.Path == "" {
			res = append(res, ErrRoutesValidationMissingPath)
		}
	}

	if !skipZero || r.Path != "" {
		u, err := url.Parse(r.Path)
		if err != nil {
			res = append(res, ErrRoutesValidationPathMalformed)
		}

		if strings.Contains(u.Path, ":") {
			res = append(res, ErrRoutesValidationFoundDynamicURL)
		}

		if !path.IsAbs(u.Path) {
			res = append(res, ErrRoutesValidationInvalidPath)
		}
	}

	if !skipZero || r.Type != "" {
		if r.Type != TypeAsync && r.Type != TypeSync {
			res = append(res, ErrRoutesValidationInvalidType)
		}
	}

	if !skipZero || r.Format != "" {
		if r.Format != FormatDefault && r.Format != FormatHTTP {
			res = append(res, ErrRoutesValidationInvalidFormat)
		}
	}

	if r.MaxConcurrency < 0 {
		res = append(res, ErrRoutesValidationNegativeMaxConcurrency)
	}

	if r.Timeout < 0 {
		res = append(res, ErrRoutesValidationNegativeTimeout)
	}

	if r.IdleTimeout < 0 {
		res = append(res, ErrRoutesValidationNegativeIdleTimeout)
	}

	if len(res) > 0 {
		return apiErrors.CompositeValidationError(res...)
	}

	return nil
}