package validation

import "strings"
import "strconv"
import "regexp"

func CheckStringRexMatch(val1 string ,val2 string) bool {
	
	    match, _ := regexp.MatchString(val2,val1)

	return match
	
}


func CheckStringMatch(val1 string ,val2 string) bool {

	return strings.ToLower(val1) == strings.ToLower(val2)

}

func CheckStringContains(val1 string ,val2 string) bool {

	val1 =  strings.ToLower(val1) 
	val2 = strings.ToLower(val2)
	
	return strings.Contains(val1,val2) 

}

func CheckStringintLess(val1 string ,val2 string) bool {
	
	i, _ := strconv.Atoi(val1)
	j, _ := strconv.Atoi(val2)
	
	if i < j {
		
		return true
	}
	
	return false
	
} 

func CheckStringintGra(val1 string ,val2 string) bool {
	
	i, _ := strconv.Atoi(val1)
	j, _ := strconv.Atoi(val2)
	
	if i > j {
		
		return true
	}
	
	return false
	
}

func CheckStringintLessEq(val1 string ,val2 string) bool {
	
	i, _ := strconv.Atoi(val1)
	j, _ := strconv.Atoi(val2)
	
	if i <= j {
		
		return true
	}
	
	return false
	
} 

func CheckStringintGraEq(val1 string ,val2 string) bool {
	
	i, _ := strconv.Atoi(val1)
	j, _ := strconv.Atoi(val2)
	
	if i >= j {
		
		return true
	}
	
	return false
	
}





func CheckArrayValueMatch(limitation string ,val string) bool {
	
	l := strings.Split(limitation, ",")
	
	for _,i := range l {
		
		if i == val { return true; break; }
	}
	
	return false;
	
}

func CheckRealArrayValueMatch(limitation []string ,val string) bool {
	
	
	for _,i := range limitation {
		
		if i == val { return true; break; }
	}
	
	return false;
	
}

func CheckLatLongMatch(tar_lat1 string,tar_lat2 string,tar_long1 string,tar_long2 string,lat string,long string) bool	{
	
	tar_la1, _ := strconv.ParseFloat(tar_lat1, 32)
	tar_la2, _ := strconv.ParseFloat(tar_lat2, 32)
	tar_lo1, _ := strconv.ParseFloat(tar_long1, 32)
	tar_lo2, _ := strconv.ParseFloat(tar_long2, 32)
	la, _ := strconv.ParseFloat(lat, 32)
	lo, _ := strconv.ParseFloat(long, 32)
	
	
	return (tar_la1 < la ) && (la < tar_la2 ) &&  (tar_lo1 <lo ) && ( lo < tar_lo2)  
	
}
