func isValidateString(data []byte, i int) (outi int,
	ok bool) {
	for ; i < len(data); i++ {
		if data[i] < ' ' {
			return i, false
		} else if data[i] == '\\' {
			i++
			if i == len(data) {
				return i, false
			}
			switch data[i] {
			default:
				return i, false
			case '"', '\\', '/', 'b', 'f', 'n', 'r', 't':
			case 'u':
				for j := 0; j < 4; j++ {
					i++
					if i >= len(data) {
						return i, false
					}
					if !((data[i] >= '0' && data[i] <= '9') ||
						(data[i] >= 'a' && data[i] <= 'f') ||
						(data[i] >= 'A' && data[i] <= 'F')) {
						return i, false
					}
				}
			}
		} else if data[i] == '"' {
			return i + 1, true
		}
	}
	return i, false
}
isValidateString checks if the string is valid or not
package gojtp
import (
	"errors"
	"fmt"
	"unicode/utf8"
)
type (
	Option func(*Verify) error
)
const (
	objectKeyValueLength string = "maxKeyLengthReached"
	stringValueLength    string = "maxStringValueLengthReached"
)
var (
	ErrInvalidJSON = errors.New("jtp.MalformedJSON")
)
type Verifier interface {
	VerifyBytes([]byte) (bool, error)
	VerifyString(string) (bool, error)
}
type Verify struct {
	MaxArrayElementCount   int
	arrayEntryCountEnabled bool
	JSONContainerDepth        int
	jsonContainerDepthEnabled bool
	ObjectEntryCount        int
	objectEntryCountEnabled bool
	ObjectKeyLength        int
	objectKeyLengthEnabled bool
	StringValueLen   int
	stringLenEnabled bool
}
func New(opt ...Option) (Verifier, error) {
	v := &Verify{}
	for _, setter := range opt {
		err := setter(v)
		if err != nil {
			return Verify{}, err
		}
	}
	return *v, nil
}
func WithMaxArrayElementCount(l int) Option {
	return func(verifier *Verify) error {
		if l == 0 {
			return nil
		}
		if l < 0 {
			return fmt.Errorf("jtp: max array element count cannot be"+
				" negative %d", l)
		}
		verifier.MaxArrayElementCount = l
		verifier.arrayEntryCountEnabled = true
		return nil
	}
}
func WithMaxContainerDepth(l int) Option {
	return func(verifier *Verify) error {
		if l == 0 {
			return nil
		}
		if l < 0 {
			return fmt.Errorf("jtp: max Container depth cannot be"+
				" negative %d", l)
		}
		verifier.JSONContainerDepth = l
		verifier.jsonContainerDepthEnabled = true
		return nil
	}
}
func WithMaxObjectKeyLength(l int) Option {
	return func(verifier *Verify) error {
		if l == 0 {
			return nil
		}
		if l < 0 {
			return fmt.Errorf("jtp: max object key length cannot be"+
				" negative %d", l)
		}
		verifier.ObjectKeyLength = l
		verifier.objectKeyLengthEnabled = true
		return nil
	}
}
func WithMaxStringLength(l int) Option {
	return func(verifier *Verify) error {
		if l == 0 {
			return nil
		}
		if l < 0 {
			return fmt.Errorf("jtp: max string length cannot be"+
				" negative %d", l)
		}
		verifier.StringValueLen = l
		verifier.stringLenEnabled = true
		return nil
	}
}
func WithMaxObjectEntryCount(l int) Option {
	return func(verifier *Verify) error {
		if l == 0 {
			return nil
		}
		if l < 0 {
			return fmt.Errorf("jtp: max array element count cannot be"+
				" negative %d", l)
		}
		verifier.ObjectEntryCount = l
		verifier.objectEntryCountEnabled = true
		return nil
	}
}
func validateStringLength(data []byte, startIndex, endIndex int,
	enabled bool, maxAllowed int,
	strType string) (err error) {
	str := data[startIndex:endIndex]
	l := utf8.RuneCount(str)
	if enabled && l-2 > maxAllowed {
		err = fmt.Errorf("jtp.%s.Max-[%d]-Allowed.Found-[%d]",
			strType, maxAllowed, l-2)
		return
	}
	return
}