<commit_before><?php

namespace helpers;

class FormValidatorImpl implements FormValidator {

	static function validateOnSubmit(\models\RegistrationForm $form) {
		$messages = [];

		if (!$form->hasField('full-name')
				|| !$form->getField('full-name')
				|| !strpos($form->getField('full-name'), " ")) {
			$messages['full-name'] = "Please provide your full name.";
		}

		if (!$form->getEmail()
			|| !filter_var($form->getEmail(), FILTER_VALIDATE_EMAIL)) {
			$messages['email'] = "Please provide your email address.";
		}

		if (!$form->hasField('phone')
				|| !$form->getField('phone')
				|| !preg_match('/^\+?[0-9 \-]{9,}$/', $form->getField('phone'))) {
			$messages['phone'] = "Please provide a phone number, including the operator code and optionally, the country code. You may use dashes and spaces.";
		}

		if ($form->getField('home-club') === 'Other'
				&& (!$form->hasField('home-club-custom')
					|| !$form->getField('home-club-custom'))) {
			$messages['home-club-custom'] = "Please provide the exact name of your home club, or choose one from the list.";
		}

		// If someone's not a member of Toastmasters, they can't hold a position
		// in the Exec Committee
		if ($form->getField('home-club') === 'None'
				&& $form->getField('exec-position') !== 'none') {
			$messages['exec-position'] = "You selected you're not a member of Toastmasters, and yet selected an Executive Committee position. This can't be right.";
		}

		if ($form->hasField('educational-awards')
				&& $form->getField('educational-awards')
				&& !preg_match('/(?:(?:^|, |,| )(CC|ACB|ACS|ACG|CL|ALB|ALS|DTM))+$/', $form->getField('educational-awards'))) {
			$messages['educational-awards'] = "Please enter your educational awards from among: CC, ACB, ACS, ACG, CL, ALB, ALS, DTM, separated by comas or spaces.";
		}

		if (!$form->hasField('accommodation-with-toastmasters')
				|| !$form->getField('accommodation-with-toastmasters')) {
			$messages['accommodation-with-toastmasters'] = "Please choose an accommodation option.";
		} else if ($form->getfield('accommodation-with-toastmasters') === "stay") {
			if (!$form->hasField('accommodation-on')
					|| !$form->getField('accommodation-on')) {
				$messages['accommodation-on'] = "Please choose the day or days you'll need accommodation on.";
			}

			if (!$form->hasField('sleep-on')
					|| !$form->getField('sleep-on')) {
				$messages['sleep-on'] = "Please choose your sleeping surface preferences.";
			}
		}

		return $messages;
	}

}

<commit_msg>Validation for meal selection for Saturday<commit_after><?php

namespace helpers;

class FormValidatorImpl implements FormValidator {

	static function validateOnSubmit(\models\RegistrationForm $form) {
		$messages = [];

		if (!$form->hasField('full-name')
				|| !$form->getField('full-name')
				|| !strpos($form->getField('full-name'), " ")) {
			$messages['full-name'] = "Please provide your full name.";
		}

		if (!$form->getEmail()
			|| !filter_var($form->getEmail(), FILTER_VALIDATE_EMAIL)) {
			$messages['email'] = "Please provide your email address.";
		}

		if (!$form->hasField('phone')
				|| !$form->getField('phone')
				|| !preg_match('/^\+?[0-9 \-]{9,}$/', $form->getField('phone'))) {
			$messages['phone'] = "Please provide a phone number, including the operator code and optionally, the country code. You may use dashes and spaces.";
		}

		if ($form->getField('home-club') === 'Other'
				&& (!$form->hasField('home-club-custom')
					|| !$form->getField('home-club-custom'))) {
			$messages['home-club-custom'] = "Please provide the exact name of your home club, or choose one from the list.";
		}

		// If someone's not a member of Toastmasters, they can't hold a position
		// in the Exec Committee
		if ($form->getField('home-club') === 'None'
				&& $form->getField('exec-position') !== 'none') {
			$messages['exec-position'] = "You selected you're not a member of Toastmasters, and yet selected an Executive Committee position. This can't be right.";
		}

		if ($form->hasField('educational-awards')
				&& $form->getField('educational-awards')
				&& !preg_match('/(?:(?:^|, |,| )(CC|ACB|ACS|ACG|CL|ALB|ALS|DTM))+$/', $form->getField('educational-awards'))) {
			$messages['educational-awards'] = "Please enter your educational awards from among: CC, ACB, ACS, ACG, CL, ALB, ALS, DTM, separated by comas or spaces.";
		}

		if (!$form->hasField('accommodation-with-toastmasters')
				|| !$form->getField('accommodation-with-toastmasters')) {
			$messages['accommodation-with-toastmasters'] = "Please choose an accommodation option.";
		} else if ($form->getfield('accommodation-with-toastmasters') === "stay") {
			if (!$form->hasField('accommodation-on')
					|| !$form->getField('accommodation-on')) {
				$messages['accommodation-on'] = "Please choose the day or days you'll need accommodation on.";
			}

			if (!$form->hasField('sleep-on')
					|| !$form->getField('sleep-on')) {
				$messages['sleep-on'] = "Please choose your sleeping surface preferences.";
			}
		}

		// Whoever goes to Saturday dinner, must choose a meal option
		if ($form->hasField('saturday-dinner-participate')
				&& (!$form->hasField('saturday-dinner-meal')
					|| !$form->getField('saturday-dinner-meal'))) {
			$messages['saturday-dinner-meal'] = "Please choose a meal option for the Saturday dinner.";
		}

		return $messages;
	}

}


{'fraction_non_alphanumeric': 0.19335572974990667, 'fraction_numerical': 0.0011198208286674132, 'mean_word_length': 4.2798029556650246, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 52, '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': '5879092', 'n_tokens_mistral': 1961, 'n_tokens_neox': 1733, 'n_words': 403}