<commit_before><?php
/**
 * Description: This is the description of the document.
 * You can add as many lines as you want.
 * Remember you're not coding for yourself. The world needs your doc.
 * Example usage:
 * <pre>
 * if (Example_Class::example()) {
 *    echo "I am an example.";
 * }
 * </pre>
 *
 * @author		<NAME> <@mvdandrieux>
 * @author		<NAME> <<EMAIL>>
 * @copyright	Copyright © 2004-2015, Hands
 * @license		http://grandcentral.fr/license MIT License
 * @access		public
 * @link		http://grandcentral.fr
 */
/********************************************************************************************/
//	We start from the form and the field
/********************************************************************************************/
//	Env
	$handled_env = $_SESSION['pref']['handled_env'];
	
//	The form
	$form = i('form', $_POST['form'], $handled_env);
//	The field
	$field = $form['field'][$_POST['field']];
//	création du champ de test
	if (isset($_POST['value'])) $field['value'] = $_POST['value'];
	$class = 'field'.ucfirst($field['type']);
	$field = new $class($field['key'], $field);

/********************************************************************************************/
//	And now we validate
/********************************************************************************************/
	if ($field->is_valid()) $return = true;
	else $return = $field->get_error();
//	Send back data in json
	// $return = array('required' => array('descr' => 'form : '.$class.' / field : '.$_POST['field'].' / value : '.$_POST['value'].''));
//	$return = 'true';
	echo json_encode($return, JSON_UNESCAPED_UNICODE);
?><commit_msg>Validation : better test<commit_after><?php
/**
 * Description: This is the description of the document.
 * You can add as many lines as you want.
 * Remember you're not coding for yourself. The world needs your doc.
 * Example usage:
 * <pre>
 * if (Example_Class::example()) {
 *    echo "I am an example.";
 * }
 * </pre>
 *
 * @author		<NAME> <@mvdandrieux>
 * @author		<NAME> <<EMAIL>>
 * @copyright	Copyright © 2004-2015, Hands
 * @license		http://grandcentral.fr/license MIT License
 * @access		public
 * @link		http://grandcentral.fr
 */
/********************************************************************************************/
//	We start from the form and the field
/********************************************************************************************/
//	Env
	$handled_env = $_SESSION['pref']['handled_env'];
	
//	The form
	$form = i('form', $_POST['form'], $handled_env);
//	The field
	$field = $form['field'][$_POST['field']];
//	création du champ de test
	if (isset($_POST['value'])) $field['value'] = $_POST['value'];
	
	if (!empty($field['type']))
	{
		$class = 'field'.ucfirst($field['type']);
		$field = new $class($field['key'], $field);

/********************************************************************************************/
//	And now we validate
/********************************************************************************************/
		if ($field->is_valid()) $return = true;
		else $return = $field->get_error();
	}
	else
	{
		$return = '';
	}
//	Send back data in json
	// $return = array('required' => array('descr' => 'form : '.$class.' / field : '.$_POST['field'].' / value : '.$_POST['value'].''));
//	$return = 'true';
	echo json_encode($return, JSON_UNESCAPED_UNICODE);
?>
{'fraction_non_alphanumeric': 0.38284023668639056, 'fraction_numerical': 0.004733727810650888, 'mean_word_length': 5.0375, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 27, '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': '5891947', 'n_tokens_mistral': 1014, 'n_tokens_neox': 952, 'n_words': 256}