// CheckValidTypesForResultMerger returns an error if the provided fields are not compatible with how ResultMerger works
511453
func CheckValidTypesForResultMerger(fields []*querypb.Field, pkFieldCount int) error {
	for i := 0; i < pkFieldCount; i++ {
		typ := fields[i].Type
		if !sqltypes.IsIntegral(typ) && !sqltypes.IsFloat(typ) && !sqltypes.IsBinary(typ) {
			return vterrors.Errorf(vtrpc.Code_FAILED_PRECONDITION, "unsupported type: %v cannot compare fields with this type", typ)
		}
	}
	return nil
}
1130130
func typeIsBool(typ reflect.Type) bool {
	k := typ.Kind()
	return k == reflect.Bool
}
996580
func checkExtensionTypes(pb extendableProto, extension *ExtensionDesc) error {
	var pbi interface{} = pb
	// Check the extended type.
	if ea, ok := pbi.(extensionAdapter); ok {
		pbi = ea.extendableProtoV1
	}
	if a, b := reflect.TypeOf(pbi), reflect.TypeOf(extension.ExtendedType); a != b {
		return fmt.Errorf("proto: bad extended type; %v does not extend %v", b, a)
	}
	// Check the range.
	if !isExtensionField(pb, extension.Field) {
		return errors.New("proto: bad extension number; not in declared ranges")
	}
	return nil
}
1152701
func InvalidValueForTypeError(val, typedObj interface{}) error {
	if verboseErrors {
		return pretty.Errorf("for type (%s), unrecognized value\n%# v", reflect.TypeOf(typedObj), val)
	}

	return pretty.Errorf("for type (%s), unrecognized (%s) value", reflect.TypeOf(typedObj), reflect.TypeOf(val))
}
493570
func (r *Result) IsValid() bool {
	if r == nil {
		return true
	}
	return len(r.Errors) == 0
}
938776
func (p provider) ReturnType() reflect.Type {
	return reflect.TypeOf(p.constructor).Out(0)
}
645272
func check_type_expr(e ast.Expr) bool {
	switch t := e.(type) {
	case *ast.StarExpr:
		return check_type_expr(t.X)
	case *ast.ArrayType:
		return check_type_expr(t.Elt)
	case *ast.SelectorExpr:
		return check_type_expr(t.X)
	case *ast.FuncType:
		a := check_func_field_list(t.Params)
		b := check_func_field_list(t.Results)
		return a && b
	case *ast.MapType:
		a := check_type_expr(t.Key)
		b := check_type_expr(t.Value)
		return a && b
	case *ast.Ellipsis:
		return check_type_expr(t.Elt)
	case *ast.ChanType:
		return check_type_expr(t.Value)
	case *ast.BadExpr:
		return false
	default:
		return true
	}
}
693340
func Fail(resultType reflect.Type) gopter.Gen {
	return func(*gopter.GenParameters) *gopter.GenResult {
		return gopter.NewEmptyResult(resultType)
	}
}
347946
func (a *aggPushDownSolver) checkValidJoin(join *Join) bool {
	return join.JoinType == InnerJoin || join.JoinType == LeftOuterJoin || join.JoinType == RightOuterJoin
}
43551
func (v mergeStrategy) MergeType(e apply.TypeElement) (apply.Result, error) {
	// No merge logic if adding or deleting a field
	if result, done := v.doAddOrDelete(e); done {
		return result, nil
	}
	// Detect conflict in TypeElement
	if err := v.doConflictDetect(e); err != nil {
		return apply.Result{}, err
	}
	return v.doMergeMap(e.GetValues())
}
796230
func (v delegatingStrategy) MergeType(diff apply.TypeElement) (apply.Result, error) {
	switch diff.GetFieldMergeType() {
	case apply.MergeStrategy:
		return v.merge.MergeType(diff)
	case apply.ReplaceStrategy:
		return v.replace.MergeType(diff)
	case apply.RetainKeysStrategy:
		return v.retainKeys.MergeType(diff)
	default:
		return v.merge.MergeType(diff)
	}
}
685130
func IsInvalidType(err error) bool {
	_, ok := Cause(err).(InvalidTypeError)
	return ok
}
453822
func (v *validate) ExtractType(field reflect.Value) (reflect.Value, reflect.Kind, bool) {
	return v.extractTypeInternal(field, false)
}
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))
}
1235141
func (b *codeGenOpBuilder) HasValidations(sh spec.CommonValidations, rt resolvedType) (hasValidations bool, hasSliceValidations bool) {
	// TODO: exclude format byte (istrfmt.Base64) from validation (issue#1548)
	hasNumberValidation := sh.Maximum != nil || sh.Minimum != nil || sh.MultipleOf != nil
	hasStringValidation := sh.MaxLength != nil || sh.MinLength != nil || sh.Pattern != ""
	hasSliceValidations = sh.MaxItems != nil || sh.MinItems != nil || sh.UniqueItems || len(sh.Enum) > 0
	hasValidations = (hasNumberValidation || hasStringValidation || hasSliceValidations || rt.IsCustomFormatter) && !rt.IsStream && !rt.IsInterface
	return
}
663236
func EnumValidator(param string, v reflect.Value) (ValidationResult, error) {
	if param == "" {
		return 0, ErrInvalidConfigValue
	}

	params := strings.Split(param, "|")

	var enum func(v reflect.Value) (ValidationResult, error)
	enum = func(v reflect.Value) (ValidationResult, error) {
		if v.Kind() == reflect.Ptr {
			v = v.Elem()
		}
		switch v.Kind() {
		case reflect.String:
			val := v.String()
			if val == "" {
				// need empty checking? use req :)
				return ValidationOK, nil
			}
			for _, value := range params {
				if val == value {
					return ValidationOK, nil
				}
			}
			return ValidationNG, nil
		case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
			val := v.Int()
			for _, value := range params {
				value2, err := strconv.ParseInt(value, 10, 0)
				if err != nil {
					return 0, ErrInvalidConfigValue
				}
				if val == value2 {
					return ValidationOK, nil
				}
			}
			return ValidationNG, nil
		case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
			val := v.Uint()
			for _, value := range params {
				value2, err := strconv.ParseUint(value, 10, 0)
				if err != nil {
					return 0, ErrInvalidConfigValue
				}
				if val == value2 {
					return ValidationOK, nil
				}
			}
			return ValidationNG, nil
		case reflect.Array, reflect.Slice:
			for i := 0; i < v.Len(); i++ {
				e := v.Index(i)
				return enum(e)
			}
		default:
			return 0, ErrValidateUnsupportedType
		}

		return ValidationOK, nil
	}

	return enum(v)
}
101847
func (s *state) validateType(value reflect.Value, typ reflect.Type) reflect.Value {
	if !value.IsValid() {
		if typ == nil || canBeNil(typ) {
			// An untyped nil interface{}. Accept as a proper nil value.
			return reflect.Zero(typ)
		}
		s.errorf("invalid value; expected %s", typ)
	}
	if typ != nil && !value.Type().AssignableTo(typ) {
		if value.Kind() == reflect.Interface && !value.IsNil() {
			value = value.Elem()
			if value.Type().AssignableTo(typ) {
				return value
			}
			// fallthrough
		}
		// Does one dereference or indirection work? We could do more, as we
		// do with method receivers, but that gets messy and method receivers
		// are much more constrained, so it makes more sense there than here.
		// Besides, one is almost always all you need.
		switch {
		case value.Kind() == reflect.Ptr && value.Type().Elem().AssignableTo(typ):
			value = value.Elem()
			if !value.IsValid() {
				s.errorf("dereference of nil pointer of type %s", typ)
			}
		case reflect.PtrTo(value.Type()).AssignableTo(typ) && value.CanAddr():
			value = value.Addr()
		default:
			s.errorf("wrong type for value; expected %s; got %s", typ, value.Type())
		}
	}
	return value
}