Example #1
0
func ValProbeName(name string) error {
	if len(name) < MinProbeName || len(name) > MaxProbeName {
		return e.New(text.ErrInvNumberChars)
	}
	if !uni.IsLetter(int32(name[0])) {
		return e.New(ErrFirstChar)
	}
	for _, v := range name {
		if !uni.IsLetter(v) && !unicode.IsDigit(v) {
			return e.Push(e.New(text.ErrInvCharacter), e.New("the character '%v' is invalid", string([]byte{byte(v)})))
		}
	}
	return nil
}
Example #2
0
func CheckDomain(domain string) error {
	for _, v := range domain {
		if !uni.IsLetter(v) && !unicode.IsDigit(v) && v != '.' {
			return e.Push(e.New("invalid domain name"), e.New("the character '%v' in redirect is invalid", string([]byte{byte(v)})))
		}
	}
	return nil
}
Example #3
0
File: tags.go Project: fcavani/tags
// Check if a tag is formed with the corrects characters
func CheckTag(tag string) error {
	for _, v := range tag {
		if !u.IsLetter(v) && !unicode.IsDigit(v) && v != ' ' && v != '-' && v != '_' && v != '.' && v != '/' && v != ':' {
			return e.Push(e.New(ErrInvalidTagChar), e.New("the character '%v' is invalid", string([]byte{byte(v)})))
		}
	}
	return nil
}
Example #4
0
// CheckHash the hash of a password.
func CheckHash(name string) error {
	for _, v := range name {
		if !uni.IsLetter(v) && !unicode.IsDigit(v) && v != '-' && v != '_' && v != '.' && v != '=' {
			return e.Push(e.New(text.ErrInvCharacter), e.New("the character '%v' in instance name is invalid", string([]byte{byte(v)})))
		}
	}
	return nil
}
Example #5
0
func CheckObjectName(name string) error {
	for _, v := range name {
		if !uni.IsLetter(v) && !unicode.IsDigit(v) && v != '-' && v != '_' && v != '*' && v != '{' && v != '}' && v != '/' && v != '.' && v != '[' && v != ']' {
			return e.Push(e.New(text.ErrInvCharacter), e.New("the character '%v' in object name is invalid", string([]byte{byte(v)})))
		}
	}
	return nil
}
Example #6
0
func CheckText(text string, min, max int) error {
	if len(text) < min || len(text) > max {
		return e.New(ErrInvNumberChars)
	}
	for _, v := range text {
		if !uni.IsLetter(v) && !unicode.IsDigit(v) && v != '\n' && v != ' ' && v != '`' && v != '~' && v != '!' && v != '@' && v != '#' && v != '$' && v != '%' && v != '^' && v != '&' && v != '*' && v != '(' && v != ')' && v != '_' && v != '-' && v != '+' && v != '=' && v != '{' && v != '}' && v != '[' && v != ']' && v != '|' && v != '\\' && v != ':' && v != ';' && v != '"' && v != '\'' && v != '?' && v != '/' && v != ',' && v != '.' {
			return e.Push(e.New(ErrInvCharacter), e.New("the character '%v' is invalid", string([]byte{byte(v)})))
		}
	}
	return nil
}
Example #7
0
func CheckLettersNumber(text string, min, max uint64) error {
	if uint64(len(text)) < min || uint64(len(text)) > max {
		return e.New(ErrInvNumberChars)
	}
	for _, v := range text {
		if !uni.IsLetter(v) && !unicode.IsDigit(v) {
			return e.Push(e.New(ErrInvCharacter), e.New("the character '%v' is invalid", string([]byte{byte(v)})))
		}
	}
	return nil
}
Example #8
0
func CheckLetters(text string, min, max int) error {
	if len(text) < min || len(text) > max {
		return e.New(ErrInvNumberChars)
	}
	for _, v := range text {
		if !uni.IsLetter(v) {
			return e.Push(e.New(ErrInvCharacter), e.New("the character '%v' is invalid", string([]byte{byte(v)})))
		}
	}
	return nil
}
Example #9
0
func CheckUrl(rawurl string, min, max int) error {
	if len(rawurl) < min || len(rawurl) > max {
		return e.Push(e.New(ErrInvUrl), e.New("invalid url length"))
	}
	for _, v := range rawurl {
		if !uni.IsLetter(v) && !unicode.IsDigit(v) && v != '/' && v != ':' && v != '[' && v != ']' && v != '?' && v != '@' && v != '.' && v != '-' && v != '_' && v != ' ' && v != '+' && v != '%' && v != '#' {
			return e.Push(e.New(ErrInvUrl), e.New("the character '%v' in redirect is invalid", string([]byte{byte(v)})))
		}
	}
	return nil
}
Example #10
0
func CheckSearch(query string, min, max int) error {
	if len(query) < min || len(query) > max {
		return e.New(ErrInvNumberChars)
	}
	for _, v := range query {
		if !uni.IsLetter(v) && !unicode.IsDigit(v) && v != '@' && v != '.' && v != '-' && v != '_' && v != ' ' && v != '+' && v != '"' {
			return e.New(ErrInvCharacter)
		}
	}
	return nil
}
Example #11
0
func CheckNameWithoutSpecials(name string, min, max int) error {
	if len(name) < min || len(name) > max {
		return e.New(ErrInvNumberChars)
	}
	for _, v := range name {
		if !uni.IsLetter(v) && !unicode.IsDigit(v) && v != ' ' && v != '&' && v != '(' && v != ')' && v != '-' && v != ':' && v != '/' && v != ',' && v != '.' && v != '_' {
			return e.Push(e.New(ErrInvCharacter), e.New("the character '%v' is invalid", string([]byte{byte(v)})))
		}
	}
	return nil
}
Example #12
0
File: tags.go Project: fcavani/tags
// Check if a set of tags are correctly formated.
func CheckTags(tags string) error {
	if len(tags) <= TagStringMin && len(tags) >= TagStringMax {
		return e.New(ErrInvalidTagsLength)
	}
	for _, v := range tags {
		if !u.IsLetter(v) && !unicode.IsDigit(v) && v != ',' && v != ' ' && v != '-' && v != '_' && v != '.' && v != '/' && v != ':' {
			return e.Push(e.New(ErrInvalidTagChar), e.New("the character '%v' is invalid", string([]byte{byte(v)})))
		}
	}
	return nil
}
Example #13
0
func ValidateRedirect(redirect string, min, max int) error {
	utf8name := utf8string.NewString(redirect)
	len := utf8name.RuneCount()
	if len < min || len > max {
		return e.New(e.ErrInvalidLength)
	}
	for _, s := range utf8name.Slice(1, len) {
		if !uni.IsLetter(s) && !unicode.IsDigit(s) && s != '/' && s != '-' && s != '_' && s != '?' && s != '&' && s != '=' && s != '%' && s != '*' && s != '+' && s != ' ' && s != ',' {
			return e.Push(e.New("the character '%v' in redirect is invalid", string([]byte{byte(s)})), e.New("invalid redirect"))
		}
	}
	return nil
}