// Validate that the given value matches all of the given regular expressions.
978859
func ValidateMatchAll(patterns ...string) FieldValidatorFunc {
	prx := make([]*regexp.Regexp, len(patterns))

	for i, rxs := range patterns {
		prx[i] = regexp.MustCompile(rxs)
	}

	return func(value interface{}) error {
		for _, rx := range prx {
			if !rx.MatchString(typeutil.String(value)) {
				return fmt.Errorf("Value does not match pattern %q", rx.String())
			}
		}

		return nil
	}
}
512038
func RegexMatch(key1 string, key2 string) bool {
	res, err := regexp.MatchString(key2, key1)
	if err != nil {
		panic(err)
	}
	return res
}
414929
func (v *RegexMatch) IsValid(errors *validate.Errors) {
	r := regexp.MustCompile(v.Expr)
	if r.Match([]byte(v.Field)) {
		return
	}

	if len(v.Message) > 0 {
		errors.Add(GenerateKey(v.Name), v.Message)
		return
	}

	errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s does not match the expected format.", v.Name))
}
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)
}
583140
func (m *HeaderMatcher) Validate() error {
	if m == nil {
		return nil
	}

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

	// no validation rules for InvertMatch

	switch m.HeaderMatchSpecifier.(type) {

	case *HeaderMatcher_ExactMatch:
		// no validation rules for ExactMatch

	case *HeaderMatcher_RegexMatch:

		if len(m.GetRegexMatch()) > 1024 {
			return HeaderMatcherValidationError{
				field:  "RegexMatch",
				reason: "value length must be at most 1024 bytes",
			}
		}

	case *HeaderMatcher_RangeMatch:

		{
			tmp := m.GetRangeMatch()

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

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

	case *HeaderMatcher_PresentMatch:
		// no validation rules for PresentMatch

	case *HeaderMatcher_PrefixMatch:

		if len(m.GetPrefixMatch()) < 1 {
			return HeaderMatcherValidationError{
				field:  "PrefixMatch",
				reason: "value length must be at least 1 bytes",
			}
		}

	case *HeaderMatcher_SuffixMatch:

		if len(m.GetSuffixMatch()) < 1 {
			return HeaderMatcherValidationError{
				field:  "SuffixMatch",
				reason: "value length must be at least 1 bytes",
			}
		}

	}

	return nil
}
454146
func (v *Validator) Match(field string, regex *regexp.Regexp) *ValidationResult {
	if !regex.MatchString(v.data.Get(field)) {
		return v.addMatchError(field)
	} else {
		return validationOk
	}
}
646857
func MatchAnyRegex(str []byte, regex []string) bool {
	for _, reg := range regex {
		if matched, _ := regexp.Match(reg, str); matched {
			return true
		}
	}

	return false
}
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
}
842287
func (b ValExprBuilder) RegExp(val interface{}) BoolExprBuilder {
	return b.makeComparisonExpr(astRegExp, makeValExpr(val))
}
1253656
func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
	if h, ok := a.t.(tHelper); ok {
		h.Helper()
	}
	return Regexp(a.t, rx, str, msgAndArgs...)
}
210601
func IsValid(expr string) bool {
	_, err := parse(expr, &match{})
	return err == nil
}
20334
func (v *requiredRule) Validate(value interface{}) error {
	value, isNil := Indirect(value)
	if v.skipNil && !isNil && IsEmpty(value) || !v.skipNil && (isNil || IsEmpty(value)) {
		return errors.New(v.message)
	}
	return nil
}
882863
func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) {
	if h, ok := a.t.(tHelper); ok {
		h.Helper()
	}
	Regexpf(a.t, rx, str, msg, args...)
}
232583
func (m *QueryParameterMatcher) Validate() error {
	if m == nil {
		return nil
	}

	if l := len(m.GetName()); l < 1 || l > 1024 {
		return QueryParameterMatcherValidationError{
			field:  "Name",
			reason: "value length must be between 1 and 1024 bytes, inclusive",
		}
	}

	// no validation rules for Value

	{
		tmp := m.GetRegex()

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

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

	return nil
}
347589
func match(regex, text string) string {
	if matched, _ := regexp.MatchString(regex, text); matched {
		return regexp.MustCompile(regex).ReplaceAllString(text, "$1")
	}
	return ""
}
396409
func (r *DateRule) Validate(value interface{}) error {
	value, isNil := Indirect(value)
	if isNil || IsEmpty(value) {
		return nil
	}

	str, err := EnsureString(value)
	if err != nil {
		return err
	}

	date, err := time.Parse(r.layout, str)
	if err != nil {
		return errors.New(r.message)
	}

	if !r.min.IsZero() && r.min.After(date) || !r.max.IsZero() && date.After(r.max) {
		return errors.New(r.rangeMessage)
	}

	return nil
}
697445
func RegExpValidator(param string, v reflect.Value) (ValidationResult, error) {
	if param == "" {
		return ValidationNG, ErrInvalidConfigValue
	}

	re, err := regexp.Compile(param)
	if err != nil {
		return ValidationNG, ErrInvalidConfigValue
	}

	switch v.Kind() {
	case reflect.String:
		if v.String() == "" {
			return ValidationOK, nil // empty is valid. if you want to check it, use req validator.
		} else if !re.MatchString(v.String()) {
			return ValidationNG, nil
		}
	default:
		return ValidationNG, ErrValidateUnsupportedType
	}

	return ValidationOK, nil
}