// Validate string with validators, return first error or nil
973183
func (vc ValidChain) Validate(s string) error {
	for _, v := range vc {
		if e := v(s); e != nil {
			return e
		}
	}

	return nil
}
21928
func (m *DoubleMatcher) Validate() error {
	if m == nil {
		return nil
	}

	switch m.MatchPattern.(type) {

	case *DoubleMatcher_Range:

		{
			tmp := m.GetRange()

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

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

	case *DoubleMatcher_Exact:
		// no validation rules for Exact

	default:
		return DoubleMatcherValidationError{
			field:  "MatchPattern",
			reason: "value is required",
		}

	}

	return nil
}
769859
func (e *InvalidValidationError) Error() string {

	if e.Type == nil {
		return "validator: (nil)"
	}

	return "validator: (nil " + e.Type.String() + ")"
}
419344
func (m *Mark) Validate(formats strfmt.Registry) error {
	var res []error

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

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
2325
func Validate(label string) error {
	if strings.Contains(label, "z") && strings.Contains(label, "Z") {
		return ErrIncompatibleLabel
	}
	return nil
}
51907
func (v *ValidationError) Error() string {
	errString := "ValidationError: "
	for idx, err := range v.Errors {
		errString = fmt.Sprintf("%v\n   %v -  %v", errString, idx, err)
	}
	return errString
}
792961
func (m *Matcher) Validate() error {
	var errs []error
	if m.NamespaceLister == nil {
		errs = append(errs, fmt.Errorf("the namespace matcher requires a namespaceLister"))
	}
	if m.Client == nil {
		errs = append(errs, fmt.Errorf("the namespace matcher requires a namespaceLister"))
	}
	return utilerrors.NewAggregate(errs)
}
813126
func (v *Validation) Validate(i interface{}, args ...string) ValidateResult {
	e := NewValidateResult()
	var err error
	switch m := i.(type) {
	case string:
		field := m
		var value, rule string
		switch len(args) {
		case 2:
			rule = args[1]
			fallthrough
		case 1:
			value = args[0]
		}
		if len(rule) == 0 {
			return e
		}
		_, err = v.validator.ValidSimple(field, value, rule)
	default:
		_, err = v.validator.Valid(i, args...)
	}
	if err != nil {
		return e.SetError(err)
	}
	if v.validator.HasError() {
		vErr := v.validator.Errors[0]
		e.SetError(vErr)
		e.SetField(vErr.Field)
		e.SetRaw(v.validator.Errors)
		v.validator.Errors = nil
	}
	return e
}
556336
func (c Code) Validate(_ interface{}) error {
	if codeRegex.Match([]byte(c)) {
		return nil
	}

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

	return errInvalidLabel
}
1353844
func (r *ResourceQuotaGeneratorV1) validate() error {
	if len(r.Name) == 0 {
		return fmt.Errorf("name must be specified")
	}
	return nil
}
157414
func (constraints *tokenConstraints) validate() (err error) {
	keys := 0
	if constraints.key != nil {
		keys++
	}
	if constraints.secret != "" {
		keys++
	}
	if keys > 1 {
		err = fmt.Errorf("duplicate key constraints")
		return
	}
	if keys < 1 {
		err = fmt.Errorf("no key constraint")
		return
	}
	return
}
377746
func (u User) Validate() error {
	if u.Login == "" {
		return NewValidationError(errors.New("invalid user login"))
	}
	if u.Email != "" {
		if _, err := mail.ParseAddress(u.Email); err != nil {
			return NewValidationError(err)
		}
	}

	return nil
}
670345
func (v *DefaultValidator) Validate(ctx context.Context, in interface{}) (interface{}, error) {
	if in == nil {
		return in, nil
	}

	v.lazyinit()
	if err := v.validate.Struct(in); err != nil {
		return nil, err
	}

	return in, nil
}
920103
func (mv *Validator) Validate(v interface{}) error {
	sv := reflect.ValueOf(v)
	st := reflect.TypeOf(v)
	if sv.Kind() == reflect.Ptr && !sv.IsNil() {
		return mv.Validate(sv.Elem().Interface())
	}
	if sv.Kind() != reflect.Struct && sv.Kind() != reflect.Interface {
		return ErrUnsupported
	}

	nfields := sv.NumField()
	m := make(ErrorMap)
	for i := 0; i < nfields; i++ {
		fname := st.Field(i).Name
		if !unicode.IsUpper(rune(fname[0])) {
			continue
		}

		f := sv.Field(i)
		// deal with pointers
		for f.Kind() == reflect.Ptr && !f.IsNil() {
			f = f.Elem()
		}
		tag := st.Field(i).Tag.Get(mv.tagName)
		if tag == "-" {
			continue
		}
		var errs ErrorArray

		if tag != "" {
			err := mv.Valid(f.Interface(), tag)
			if errors, ok := err.(ErrorArray); ok {
				errs = errors
			} else {
				if err != nil {
					errs = ErrorArray{err}
				}
			}
		}

		mv.deepValidateCollection(f, fname, m) // no-op if field is not a struct, interface, array, slice or map

		if len(errs) > 0 {
			m[st.Field(i).Name] = errs
		}
	}

	if len(m) > 0 {
		return m
	}
	return nil
}
1081313
func (v *MatchRule) Validate(value interface{}) error {
	value, isNil := Indirect(value)
	if isNil {
		return nil
	}

	isString, str, isBytes, bs := StringOrBytes(value)
	if isString && (str == "" || v.re.MatchString(str)) {
		return nil
	} else if isBytes && (len(bs) == 0 || v.re.Match(bs)) {
		return nil
	}
	return errors.New(v.message)
}
1166157
func (config StringsConfig) Validate() error {
	if config.Handler == nil {
		return errors.NotValidf("nil Handler")
	}
	return nil
}