// IsASCII check if the string contains ASCII chars only. Empty string is valid.
2604
func IsASCII(str string) bool {
	if IsNull(str) {
		return true
	}
	return rxASCII.MatchString(str)
}
937770
func (schema *Schema) TypeIs(typeName string) bool {
	if schema.Type != nil {
		// the schema Type is either a string or an array of strings
		if schema.Type.String != nil {
			return (*(schema.Type.String) == typeName)
		} else if schema.Type.StringArray != nil {
			for _, n := range *(schema.Type.StringArray) {
				if n == typeName {
					return true
				}
			}
		}
	}
	return false
}
307438
func checkIsHex(s string) error {
	switch {
	case s == "":
		return fmt.Errorf("empty hex string")
	case len(s)%2 != 0:
		return fmt.Errorf("uneven number of symbols in the hex string")
	}
	for _, c := range s {
		if !((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f')) {
			return fmt.Errorf("bad lowercase hex string %q, wrong char %c", s, c)
		}
	}
	return nil
}
315766
func StringInSlice(valid []string, ignoreCase bool) schema.SchemaValidateFunc {
	return func(i interface{}, k string) (s []string, es []error) {
		v, ok := i.(string)
		if !ok {
			es = append(es, fmt.Errorf("expected type of %s to be string", k))
			return
		}

		for _, str := range valid {
			if v == str || (ignoreCase && strings.ToLower(v) == strings.ToLower(str)) {
				return
			}
		}

		es = append(es, fmt.Errorf("expected %s to be one of %v, got %s", k, valid, v))
		return
	}
}
370714
func isAscii(s string) bool {
	for _, c := range s {
		if c > unicode.MaxASCII || unicode.IsControl(c) {
			return false
		}
	}
	return true
}
616513
func OnlyAsciiWords(r rune) bool {
	switch {
	case r >= 'A' && r <= 'Z':
		return false
	case r >= 'a' && r <= 'z':
		return false
	case r == ' ':
		return false
	default:
		return true
	}
}
893753
func asciiEqualFold(s, t []byte) bool {
	if len(s) != len(t) {
		return false
	}
	for i, sb := range s {
		tb := t[i]
		if sb == tb {
			continue
		}
		if ('a' <= sb && sb <= 'z') || ('A' <= sb && sb <= 'Z') {
			if sb&caseMask != tb&caseMask {
				return false
			}
		} else {
			return false
		}
	}
	return true
}
1276116
func (v *StringsMatch) IsValid(errors *validate.Errors) {
	if strings.TrimSpace(v.Field) != strings.TrimSpace(v.Field2) {
		if v.Message == "" {
			v.Message = fmt.Sprintf("%s does not equal %s.", v.Field, v.Field2)
		}
		errors.Add(GenerateKey(v.Name), v.Message)
	}
}
223445
func typeIsString(typ reflect.Type) bool {
	k := typ.Kind()
	return k == reflect.String || ((k == reflect.Slice || k == reflect.Array) && typ.Elem().Kind() == reflect.Uint8)
}
75136
func (a *Automaton) IsAccept(state int) bool {
	return a.isAccept.Get(int64(state))
}
416905
func IsAlpha(s string) bool {
	for _, v := range s {
		if ('Z' < v || v < 'A') && ('z' < v || v < 'a') {
			return false
		}
	}
	return true
}
947810
func IsLowerCase(str string) bool {
	if IsNull(str) {
		return true
	}
	return str == strings.ToLower(str)
}
755253
func isValidURL(s string) bool {
	u, err := url.Parse(s)
	return err == nil && u.IsAbs()
}
1182487
func IntFromASCII(bts []byte) (ret int, ok bool) {
	// ASCII numbers all start with the high-order bits 0011.
	// If you see that, and the next bits are 0-9 (0000 - 1001) you can grab those
	// bits and interpret them directly as an integer.
	var n int
	if n = len(bts); n < 1 {
		return 0, false
	}
	for i := 0; i < n; i++ {
		if bts[i]&0xf0 != 0x30 {
			return 0, false
		}
		ret += int(bts[i]&0xf) * pow(10, n-i-1)
	}
	return ret, true
}
1189348
func IsAbs(os, path string) bool {
	if os == "windows" {
		// FIXME: copy hideous logic from Go's
		// src/path/filepath/path_windows.go into somewhere where we can
		// put 3-clause BSD licensed code.
		return windowsAbs.MatchString(path)
	}
	sep := Separator(os)

	// POSIX has [1]:
	//
	// > If a pathname begins with two successive <slash> characters,
	// > the first component following the leading <slash> characters
	// > may be interpreted in an implementation-defined manner,
	// > although more than two leading <slash> characters shall be
	// > treated as a single <slash> character.
	//
	// And Boost treats // as non-absolute [2], but Linux [3,4], Python
	// [5] and Go [6] all treat // as absolute.
	//
	// [1]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13
	// [2]: https://github.com/boostorg/filesystem/blob/boost-1.64.0/test/path_test.cpp#L861
	// [3]: http://man7.org/linux/man-pages/man7/path_resolution.7.html
	// [4]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/filesystems/path-lookup.md?h=v4.12#n41
	// [5]: https://github.com/python/cpython/blob/v3.6.1/Lib/posixpath.py#L64-L66
	// [6]: https://go.googlesource.com/go/+/go1.8.3/src/path/path.go#199
	return strings.HasPrefix(path, string(sep))
}
599920
func IsPrintableASCII(str string) bool {
	if IsNull(str) {
		return true
	}
	return rxPrintableASCII.MatchString(str)
}
515522
func OnlyAsciiWordsAndNumbers(r rune) bool {
	switch {
	case r >= 'A' && r <= 'Z':
		return false
	case r >= 'a' && r <= 'z':
		return false
	case r >= '0' && r <= '9':
		return false
	case r == ' ':
		return false
	default:
		return true
	}
}