gitlab.com/evatix-go/core@v1.3.55/coredata/coredynamic/ReflectKindValidation.go (about)

     1  package coredynamic
     2  
     3  import (
     4  	"reflect"
     5  
     6  	"gitlab.com/evatix-go/core/errcore"
     7  )
     8  
     9  func ReflectKindValidation(
    10  	expectedKind reflect.Kind,
    11  	anyItem interface{},
    12  ) error {
    13  	actualKind := reflect.
    14  		ValueOf(anyItem).
    15  		Kind()
    16  
    17  	if actualKind == expectedKind {
    18  		return nil
    19  	}
    20  
    21  	return errcore.ExpectingErrorSimpleNoType(
    22  		"ReflectKindValidation: reflect kind validation failed",
    23  		expectedKind,
    24  		actualKind)
    25  }