<commit_before>/*!
 * Formtools v1.1.0 (http://github.io/nyxgear/formtools)
 * Copyright 2016 nyxgear
 * Licensed under the MIT license
 */
(function ( $ ) {
	/* global moment, jQuery */
	var form;
	var s;
	var t;
	
	var clearErrorsAndFill = function (data) {

		form.find(s.error.class).removeClass(s.error.class.replace('.', ''));
		if (s.error.fields) {
			$(s.error.fields).text('');
		}

		if (s.verbose || data) {
			form.find('input, select, textarea').each(function() {
				var f =  $(this);

				if (f.data('ft-date-format') !== undefined) {
					s.dateFormat = f.data('ft-date-format');
				}

				if (s.verbose) {
					if (f.attr('aria-describedby')) {
						$('#' + f.attr('aria-describedby')).detach();
					}
				}

				if (data && (data[ f.attr('name')] !== undefined) ) {

					if (f.attr('type') == 'date') {
						var mDate = moment(data[ f.attr('name')], s.dateFormat, true);
						f.val(mDate.format(s.dateFormat));

					} else {
						f.val(data[f.attr('name')]);
					}

				}
			});
		}
	};

	var fieldValidate = function (f) {
		var isValid = true;

		s = $.extend(
			true,
			{},
			_settings,
			$.fn.formtools.settings,
			form.data('ft-settings'),
			formTagSettings(),
			fieldTagSettings(f)
		);
	
		/** VALIDATE FIELD **/
		// if optional and there's no content in filed, skip validation
		if (f.val() || !s.v.ftOptional) {
	
			// ft-required
			if (s.v.ftRequired && !f.val()) {
				isValid = false;
				s.error.dMsg = _t('ft-required');
			}
	
			// ft-minlength
			if (s.v.ftMinLength && (f.val().length < s.v.ftMinLength)) {
				isValid = false;
				s.error.dMsg = _t('ft-minlength') + ' ' + s.v.ftMinLength;
			}
	
			// regex
			if (s.v.ftRegex) {
				var regex = new RegExp(s.v.ftRegex);
	
				if (!regex.test(f.val())) {
					isValid = false;
					s.error.dMsg = _t('ft-regex');
				}
			}
	
			if (f.prop('tagName')!='SELECT' && f.val().length > 0) {
	
				switch (f.attr('type')) {
	
					case 'email':
						if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(f.val())) {
							isValid = false;
							s.error.dMsg = _t('ft-email-validation');
						}
						break;
	
					case 'date':
						if (s.v.ftDateFormat) {
							var dateRange = {};
							if (s.v.ftDateRange) {
								dateRange = s.v.ftDateRange.split(':');
							}
	
							// ft-date-format
							var mDate = moment(f.val(), s.v.ftDateFormat, true);
							if (!mDate.isValid()) {
								isValid = false;
								s.error.dMsg = _t('ft-date-validation') + ' ' + s.v.ftDateFormat;
							}
	
							// ft-date-range
							else if(dateRange[0] !== undefined && dateRange[1] !== undefined) {
								if (dateRange[0]) {
									dateRange.min = moment(dateRange[0], moment.ISO_8601);
									if (dateRange.min.isAfter(mDate)) {
										isValid = false;
										s.error.dMsg = _t('ft-date-after') + ' ' + dateRange.min.format(s.v.ftDateFormat);
									}
								}
								if (dateRange[1]) {
									dateRange.max = moment(dateRange[1], moment.ISO_8601);
									if (dateRange.max.isBefore(mDate)) {
										isValid = false;
										s.error.dMsg = _t('ft-date-before') + ' ' + dateRange.max.format(s.v.ftDateFormat);
									}
								}
							}
						}
	
						break;
				}
			}
		}
	
		/** SHOW ERRORS **/
		if (!isValid) {
			f.closest(s.error.parent).addClass(s.error.class.replace('.', ''));
	
			// if custom error msg is defined then use it
			if (!s.error.msg) {
				s.error.msg = s.error.dMsg;
			}
	
			if (s.verbose) {
				var errorMsgId = f.attr('id');
	
				if (errorMsgId === undefined) {
					errorMsgId = new Date().getTime();
				}
	
				errorMsgId = '_ft-err-' + errorMsgId;
	
				f.attr('aria-describedby', errorMsgId);
				$.fn.formtools.formatErrorMsg(f,errorMsgId, s.error.msg);
	
			}
	
			if (s.error.fields) {
				$(s.error.fields).append(s.error.msg + '<br>');
			}
		}
	
	
		return isValid;
	};
	
	var reset = function (data) {
		s.hooks.preReset(form, data);
	
		form.trigger('reset');
		clearErrorsAndFill(data);
	
		s.hooks.postReset(form, data);
	};
	
	var formValidate = function () {<commit_msg>fix the strict match during errorMsgId<commit_after>/*!
 * Formtools v1.1.0 (http://github.io/nyxgear/formtools)
 * Copyright 2016 nyxgear
 * Licensed under the MIT license
 */
(function ( $ ) {
	/* global moment, jQuery */
	var form;
	var s;
	var t;
	
	var clearErrorsAndFill = function (data) {

		form.find(s.error.class).removeClass(s.error.class.replace('.', ''));
		if (s.error.fields) {
			$(s.error.fields).text('');
		}

		if (s.verbose || data) {
			form.find('input, select, textarea').each(function() {
				var f =  $(this);

				if (f.data('ft-date-format') !== undefined) {
					s.dateFormat = f.data('ft-date-format');
				}

				if (s.verbose) {
					if (f.attr('aria-describedby')) {
						$('#' + f.attr('aria-describedby')).detach();
					}
				}

				if (data && (data[ f.attr('name')] !== undefined) ) {

					if (f.attr('type') == 'date') {
						var mDate = moment(data[ f.attr('name')], s.dateFormat, true);
						f.val(mDate.format(s.dateFormat));

					} else {
						f.val(data[f.attr('name')]);
					}

				}
			});
		}
	};

	var fieldValidate = function (f) {
		var isValid = true;

		s = $.extend(
			true,
			{},
			_settings,
			$.fn.formtools.settings,
			form.data('ft-settings'),
			formTagSettings(),
			fieldTagSettings(f)
		);
	
		/** VALIDATE FIELD **/
		// if optional and there's no content in filed, skip validation
		if (f.val() || !s.v.ftOptional) {
	
			// ft-required
			if (s.v.ftRequired && !f.val()) {
				isValid = false;
				s.error.dMsg = _t('ft-required');
			}
	
			// ft-minlength
			if (s.v.ftMinLength && (f.val().length < s.v.ftMinLength)) {
				isValid = false;
				s.error.dMsg = _t('ft-minlength') + ' ' + s.v.ftMinLength;
			}
	
			// regex
			if (s.v.ftRegex) {
				var regex = new RegExp(s.v.ftRegex);
	
				if (!regex.test(f.val())) {
					isValid = false;
					s.error.dMsg = _t('ft-regex');
				}
			}
	
			if (f.prop('tagName')!='SELECT' && f.val().length > 0) {
	
				switch (f.attr('type')) {
	
					case 'email':
						if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(f.val())) {
							isValid = false;
							s.error.dMsg = _t('ft-email-validation');
						}
						break;
	
					case 'date':
						if (s.v.ftDateFormat) {
							var dateRange = {};
							if (s.v.ftDateRange) {
								dateRange = s.v.ftDateRange.split(':');
							}
	
							// ft-date-format
							var mDate = moment(f.val(), s.v.ftDateFormat, true);
							if (!mDate.isValid()) {
								isValid = false;
								s.error.dMsg = _t('ft-date-validation') + ' ' + s.v.ftDateFormat;
							}
	
							// ft-date-range
							else if(dateRange[0] !== undefined && dateRange[1] !== undefined) {
								if (dateRange[0]) {
									dateRange.min = moment(dateRange[0], moment.ISO_8601);
									if (dateRange.min.isAfter(mDate)) {
										isValid = false;
										s.error.dMsg = _t('ft-date-after') + ' ' + dateRange.min.format(s.v.ftDateFormat);
									}
								}
								if (dateRange[1]) {
									dateRange.max = moment(dateRange[1], moment.ISO_8601);
									if (dateRange.max.isBefore(mDate)) {
										isValid = false;
										s.error.dMsg = _t('ft-date-before') + ' ' + dateRange.max.format(s.v.ftDateFormat);
									}
								}
							}
						}
	
						break;
				}
			}
		}
	
		/** SHOW ERRORS **/
		if (!isValid) {
			f.closest(s.error.parent).addClass(s.error.class.replace('.', ''));
	
			// if custom error msg is defined then use it
			if (!s.error.msg) {
				s.error.msg = s.error.dMsg;
			}
	
			if (s.verbose) {
				var errorMsgId = (f.attr('id') || (new Date().getTime()));

				errorMsgId = '_ft-err-' + errorMsgId;
	
				f.attr('aria-describedby', errorMsgId);
				$.fn.formtools.formatErrorMsg(f, errorMsgId, s.error.msg);
	
			}
	
			if (s.error.fields) {
				$(s.error.fields).append(s.error.msg + '<br>');
			}
		}
	
	
		return isValid;
	};
	
	var reset = function (data) {
		s.hooks.preReset(form, data);
	
		form.trigger('reset');
		clearErrorsAndFill(data);
	
		s.hooks.postReset(form, data);
	};
	
	var formValidate = function () {
{'fraction_non_alphanumeric': 0.19776258545680547, 'fraction_numerical': 0.005469235550031076, 'mean_word_length': 2.1903251387787472, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6565045', 'n_tokens_mistral': 3982, 'n_tokens_neox': 3016, 'n_words': 504}