package checkfn

import (
	
	
	
	
	
)

// IsNil value check
func ( any) bool {
	if  == nil {
		return true
	}

	 := reflect.ValueOf()
	switch .Kind() {
	case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
		return .IsNil()
	default:
		return false
	}
}

// IsSimpleKind kind in: string, bool, intX, uintX, floatX
func ( reflect.Kind) bool {
	if reflect.String ==  {
		return true
	}
	return  > reflect.Invalid &&  <= reflect.Float64
}

// IsEqual determines if two objects are considered equal.
//
// TIP: cannot compare function type
func (,  any) bool {
	if  == nil ||  == nil {
		return  == 
	}

	,  := .([]byte)
	if ! {
		return reflect.DeepEqual(, )
	}

	,  := .([]byte)
	if ! {
		return false
	}

	if  == nil ||  == nil {
		return  == nil &&  == nil
	}
	return bytes.Equal(, )
}

// Contains try loop over the data check if the data includes the element.
//
// data allow types: string, map, array, slice
//
//	map         - check key exists
//	string      - check sub-string exists
//	array,slice - check sub-element exists
//
// Returns:
//   - valid: data is valid
//   - found: element was found
//
// return (false, false) if impossible.
// return (true, false) if element was not found.
// return (true, true) if element was found.
func (,  any) (,  bool) {
	if  == nil {
		return false, false
	}

	 := reflect.ValueOf()
	 := reflect.TypeOf()
	 := .Kind()

	// string
	if  == reflect.String {
		return true, strings.Contains(.String(), fmt.Sprint())
	}

	// map
	if  == reflect.Map {
		 := .MapKeys()
		for  := 0;  < len(); ++ {
			if IsEqual([].Interface(), ) {
				return true, true
			}
		}
		return true, false
	}

	// array, slice - other return false
	if  != reflect.Slice &&  != reflect.Array {
		return false, false
	}

	for  := 0;  < .Len(); ++ {
		if IsEqual(.Index().Interface(), ) {
			return true, true
		}
	}
	return true, false
}

// StringsContains check string slice contains sub-string
func ( []string,  string) bool {
	for ,  := range  {
		if  ==  {
			return true
		}
	}
	return false
}

var (
	// check is number: int or float
	numReg = regexp.MustCompile(`^[-+]?\d*\.?\d+$`)
	// is positive number: int or float
	pNumReg = regexp.MustCompile(`^\d*\.?\d+$`)
)

// IsNumeric returns true if the given string is a numeric, otherwise false.
func ( string) bool {
	if  == "" {
		return false
	}
	return numReg.MatchString()
}

// IsPositiveNum check input string is positive number
func ( string) bool {
	if  == "" {
		return false
	}
	if [0] == '-' {
		return false
	}
	return pNumReg.MatchString()
}

// IsHttpURL check input is http/https url
func ( string) bool {
	return strings.HasPrefix(, "http://") || strings.HasPrefix(, "https://")
}

// IndexByteAfter find index of byte after startIndex. return -1 if not found
//
// eg:
//
//	IndexByteAfter("abcabc", 'b', 0) = 1
//	IndexByteAfter("abcabc", 'b', 2) = 4
func ( string,  byte,  int) int {
	 := strings.IndexByte([:], )
	if  < 0 {
		return -1
	}
	return  + 
}