<commit_before>package endpoints

import (
	"fmt"
)

/*
 * Parameter / Request Validation
 */

// Check if the value is not longer than a given length
func ValidateLength(value string, maxLength int) error {
	if len(value) > maxLength {
		return fmt.Errorf("Provided param value is too long.")
	}
	return nil
}

func ValidateCharset(value string, alphabet string) error {
	for i := 0; i < len(value); i++ {
		c := value[i]
		ok := false
		for j := 0; j < len(alphabet); j++ {
			if alphabet[j] == c {
				ok = true
				break
			}
		}
		if !ok {
			return fmt.Errorf("Invalid character in param value")
		}
	}<commit_msg>fix charset validator on utf-8<commit_after>package endpoints

import (
	"fmt"
)

/*
 * Parameter / Request Validation
 */

// Check if the value is not longer than a given length
func ValidateLength(value string, maxLength int) error {
	if len(value) > maxLength {
		return fmt.Errorf("Provided param value is too long.")
	}
	return nil
}

func ValidateCharset(value string, alphabet string) error {
	for _, check := range value {
		ok := false
		for _, char := range alphabet {
			if char == check {
				ok = true
				break
			}
		}
		if !ok {
			return fmt.Errorf("Invalid character in param value")
		}
	}
{'fraction_non_alphanumeric': 0.11310008136696502, 'fraction_numerical': 0.0024410089503661514, 'mean_word_length': 3.1137123745819397, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6094756', 'n_tokens_mistral': 440, 'n_tokens_neox': 394, 'n_words': 142}