<commit_before><?php
if (!defined('BACKEND_ROOT')) {
	header('Location: /error_404');
	exit ;
}

class MValidate {

	// The email function uses regular expressions to check the validity of an e-mail address.
	public static function email($email) {

		if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
			return TRUE;
		}

		return FALSE;

	}

	// Validates that a variable is declared, exists in memory, and has some value.
	// "", " ", array(), 0, FALSE will return TRUE as they are declared variables.
	// An undeclared variable or NULL will return FALSE.
	public static function optional(&$input) {
		return isset($input);
	}

	// Validates that a variable is decalred and has a non empty value.
	// 0, FALSE will return TRUE.
	// "", " ", array(), an undeclared variable, and NULL will return FALSE.
	public static function required(&$input) {

		if ($input === 0 || $input === FALSE) {
			return TRUE;
		}

		// Strip the whitespace
		$input = str_replace(' ', '', $input);

		if (!empty($input)) {
			return TRUE;
		}

		return FALSE;
	}

	// Validates that a variable contains only the values in the array.
	// The input can not have any values other than what is in the array.
	public static function only_contain($input, $choices) {

		// Set a default valid
		// The loop will change this to FALSE if it isn't valid
		$valid = TRUE;

		// If input is a string convert it to an array
		if (is_string($input)) {
			$input = str_split($input);
		}

		// Loop over the input<commit_msg>Updated MValidate required function. It was removing spaces because it was passing by reference.<commit_after><?php
if (!defined('BACKEND_ROOT')) {
	header('Location: /error_404');
	exit ;
}

class MValidate {

	// The email function uses regular expressions to check the validity of an e-mail address.
	public static function email($email) {

		if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
			return TRUE;
		}

		return FALSE;

	}

	// Validates that a variable is declared, exists in memory, and has some value.
	// "", " ", array(), 0, FALSE will return TRUE as they are declared variables.
	// An undeclared variable or NULL will return FALSE.
	public static function optional(&$input) {
		return isset($input);
	}

	// Validates that a variable is decalred and has a non empty value.
	// 0, FALSE will return TRUE.
	// "", " ", array(), an undeclared variable, and NULL will return FALSE.
	public static function required(&$input) {

		if ($input === 0 || $input === FALSE) {
			return TRUE;
		}

		// Strip the whitespace
		$inputNew = str_replace(' ', '', $input);

		if (!empty($inputNew)) {
			return TRUE;
		}

		return FALSE;
	}

	// Validates that a variable contains only the values in the array.
	// The input can not have any values other than what is in the array.
	public static function only_contain($input, $choices) {

		// Set a default valid
		// The loop will change this to FALSE if it isn't valid
		$valid = TRUE;

		// If input is a string convert it to an array
		if (is_string($input)) {
			$input = str_split($input);
		}

		// Loop over the input
{'fraction_non_alphanumeric': 0.11462064474112667, 'fraction_numerical': 0.0039075219798111365, 'mean_word_length': 3.278551532033426, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '6604461', 'n_tokens_mistral': 996, 'n_tokens_neox': 898, 'n_words': 382}