// Helper method to check whether a number is too short to be a regular
// length phone number in a region.
161254
func isShorterThanPossibleNormalNumber(
	regionMetadata *PhoneMetadata,
	number string) bool {

	pat, ok := readFromRegexCache(regionMetadata.GetGeneralDesc().GetNationalNumberPattern())
	if !ok {
		patP := regionMetadata.GetGeneralDesc().GetNationalNumberPattern()
		pat = regexp.MustCompile(patP)
		writeToRegexCache(patP, pat)
	}
	return testNumberLengthAgainstPattern(pat, number) == TOO_SHORT
}
1115717
func GetExampleNumberForNonGeoEntity(countryCallingCode int) *PhoneNumber {
	var metadata *PhoneMetadata = getMetadataForNonGeographicalRegion(countryCallingCode)
	if metadata == nil {
		return nil
	}
	var desc *PhoneNumberDesc = metadata.GetTollFree()

	if countryCallingCode == 979 {
		desc = metadata.GetPremiumRate()
	}

	exNum := desc.GetExampleNumber()
	if len(exNum) > 0 {
		num, err := Parse("+"+strconv.Itoa(countryCallingCode)+exNum, "ZZ")
		if err != nil {
			return nil
		}
		return num
	}
	return nil
}
130030
func rawInputContainsNationalPrefix(rawInput, nationalPrefix, regionCode string) bool {
	normalizedNationalNumber := NormalizeDigitsOnly(rawInput)
	if strings.HasPrefix(normalizedNationalNumber, nationalPrefix) {
		// Some Japanese numbers (e.g. 00777123) might be mistaken to
		// contain the national prefix when written without it
		// (e.g. 0777123) if we just do prefix matching. To tackle that,
		// we check the validity of the number if the assumed national
		// prefix is removed (777123 won't be valid in Japan).
		num, err := Parse(normalizedNationalNumber[len(nationalPrefix):], regionCode)
		if err != nil {
			return false
		}
		return IsValidNumber(num)

	}
	return false
}
1077148
func (r Locale_Country) IsEuropeanUnionCountry(iso2CountryCode *string) (resp bool, err error) {
	params := []interface{}{
		iso2CountryCode,
	}
	err = r.Session.DoRequest("SoftLayer_Locale_Country", "isEuropeanUnionCountry", params, &r.Options, &resp)
	return
}
1056079
func IsValidLangRegCode(s string) bool {

	// all valid codes are 5 characters long
	if len(s) != 5 {
		return false
	}

	// the middle (third) character must be a '_' char
	if s[2] != '_' {
		return false
	}

	// check the language code, which should be the first two characters in s
	if !IsValidLanguageCode(s[:2]) {
		return false
	}

	// check the region code, which should be the last two characters in s
	if !IsValidRegionCode(s[3:]) {
		return false
	}
	return true
}
476974
func IsNumeric(str string) bool {
	if IsNull(str) {
		return true
	}
	return rxNumeric.MatchString(str)
}
446798
func isNationalNumberSuffixOfTheOther(firstNumber, secondNumber *PhoneNumber) bool {
	var (
		firstNumberNationalNumber = strconv.FormatUint(
			firstNumber.GetNationalNumber(), 10)
		secondNumberNationalNumber = strconv.FormatUint(
			secondNumber.GetNationalNumber(), 10)
	)
	// Note that endsWith returns true if the numbers are equal.
	return strings.HasSuffix(firstNumberNationalNumber, secondNumberNationalNumber) ||
		strings.HasSuffix(secondNumberNationalNumber, firstNumberNationalNumber)
}
83261
func (fng *FakeNumberGenerator) RandomLocalNumberUSUniqueAreaCodeSet(set map[uint64]int8, acs []uint16) (uint64, map[uint64]int8) {
	try := fng.RandomLocalNumberUSAreaCodes(acs)
	_, ok := set[try]
	for ok {
		try := fng.RandomLocalNumberUSAreaCodes(acs)
		_, ok = set[try]
	}
	set[try] = 1
	return try, set
}
240601
func (q *SimpleQueryStringQuery) FuzzyPrefixLength(fuzzyPrefixLength int) *SimpleQueryStringQuery {
	q.fuzzyPrefixLength = fuzzyPrefixLength
	return q
}
1189480
func GetExampleNumberForType(regionCode string, typ PhoneNumberType) *PhoneNumber {
	// Check the region code is valid.
	if !isValidRegionCode(regionCode) {
		return nil
	}
	//PhoneNumberDesc (pointer?)
	var desc = getNumberDescByType(getMetadataForRegion(regionCode), typ)
	exNum := desc.GetExampleNumber()
	if len(exNum) > 0 {
		num, err := Parse(exNum, regionCode)
		if err != nil {
			return nil
		}
		return num
	}
	return nil
}
60995
func IsValidRegionCode(s string) bool {
	_, err := RegionCodeInfo(s)
	if err != nil {
		return false
	}
	return true
}
435585
func IsUTFNumeric(s string) bool {
	for _, v := range s {
		if unicode.IsNumber(v) == false {
			return false
		}
	}
	return true
}
255737
func checkShortMatch(alg digest.Algorithm, hex, shortAlg, shortHex string) bool {
	if len(hex) == len(shortHex) {
		if hex != shortHex {
			return false
		}
		if len(shortAlg) > 0 && string(alg) != shortAlg {
			return false
		}
	} else if !strings.HasPrefix(hex, shortHex) {
		return false
	} else if len(shortAlg) > 0 && string(alg) != shortAlg {
		return false
	}
	return true
}
466272
func IsRateLimit(err error) bool {
	re, ok := err.(rateLimitError)
	return ok && re.IsRateLimit()
}
747184
func isValidRegionCode(regionCode string) bool {
	_, contains := readFromSupportedRegions(regionCode)
	return len(regionCode) != 0 && contains
}
1216642
func ValidateLengths(lens ...lengther) (int, error) {
	lenLen := len(lens)
	if lenLen == 0 {
		return 0, nil
	}
	firstLen := lens[0].Length()
	shortest := firstLen
	for i, l := range lens[1:lenLen] {
		dLen := l.Length()
		if dLen < firstLen {
			log.Warnf("charts.ValidateLengths: dataset at index %d has mismatched length %d != %d", i+1, dLen, firstLen)
			if dLen < shortest {
				shortest = dLen
			}
		}
	}
	if shortest < firstLen {
		return shortest, fmt.Errorf("data length mismatch")
	}
	return firstLen, nil
}
1207649
func InvalidLengthError(ctx string, target interface{}, ln, value int, min bool) error {
	comp := "greater than or equal to"
	if !min {
		comp = "less than or equal to"
	}
	msg := fmt.Sprintf("length of %s must be %s %d but got value %#v (len=%d)", ctx, comp, value, target, ln)
	return ErrInvalidRequest(msg, "attribute", ctx, "value", target, "len", ln, "comp", comp, "expected", value)
}