<commit_before>const config = require('./config');
const deepmerge = require('deepmerge');

const ParameterError = require('./errors/ParameterError');

class LeagueUtil { // TODO: move useful things from util.js here
	// TODO: maybe split into more specific classes instead of "Util" class
	static normalizeSummonerName(name){
		return name.toLowerCase().replace(/ /g, '');
	}
	/**
	 * @return null if the name is valid, else the matching characters that are invalid*/
	static validateSummonerNameInputCharacters(name){ // TODO: add platformID based character validation
		// validating only allowed characters
		//  https://developer.riotgames.com/getting-started.html
		// regexp matches all unicode and ASCII letters and allowed other chars (space, dot and underscore)
		// needs testing for the unicode characters

		// NA/OCE:
		// 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
		// EUW:
		// 	0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĄąĆćĘęıŁłŃńŒœŚśŠšŸŹźŻżŽžƒˆˇˉμﬁﬂ
		// EUNE:
		// 	0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĂăĄąĆćĘęıŁłŃńŐőŒœŚśŞşŠšŢţŰűŸŹźŻżŽžƒȘșȚțˆˇˉΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩάέήίαβγδεζηθικλμνξοπρςστυφχψωόύώﬁﬂ
		// Brazil:
		// 	0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÀÁÂÃÇÉÊÍÓÔÕÚàáâãçéêíóôõú
		// Russia:
		// 	0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя
		// Turkey:
		// 	ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïð 0123456789ABCDEFGĞHIİJKLMNOPQRSŞTUVWXYZabcçdefgğhıijklmnoöpqrsştuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿıŁłŒœŠšŸŽžƒˆˇˉμﬁﬂĄąĘęÓóĆćŁłŃńŚśŹźŻż
		// LATAM:
		// 	0123456789ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚÜ abcdefghijklmnñopqrstuvwxyzáéíóúü

		return name.match(/[^\d\u00BF-\u1FFF\u2C00-\uD7FF\w _\.]+/g);
	}
	static validateSummonerNameInputLength(name){
		return name.length <= 16;
	}

	static getPlatformIdForRegion(region){
		const mapping = LeagueUtil.getMappingRegionToPlatformId();
		if(!region){
			throw new ParameterError('region is missing');<commit_msg>feat (LeagueUtil) add validation method for platformIds<commit_after>const config = require('./config');
const deepmerge = require('deepmerge');

const ParameterError = require('./errors/ParameterError');

class LeagueUtil { // TODO: move useful things from util.js here
	// TODO: maybe split into more specific classes instead of "Util" class
	static normalizeSummonerName(name){
		return name.toLowerCase().replace(/ /g, '');
	}
	/**
	 * @return null if the name is valid, else the matching characters that are invalid*/
	static validateSummonerNameInputCharacters(name){ // TODO: add platformID based character validation
		// validating only allowed characters
		//  https://developer.riotgames.com/getting-started.html
		// regexp matches all unicode and ASCII letters and allowed other chars (space, dot and underscore)
		// needs testing for the unicode characters

		// NA/OCE:
		// 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
		// EUW:
		// 	0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĄąĆćĘęıŁłŃńŒœŚśŠšŸŹźŻżŽžƒˆˇˉμﬁﬂ
		// EUNE:
		// 	0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĂăĄąĆćĘęıŁłŃńŐőŒœŚśŞşŠšŢţŰűŸŹźŻżŽžƒȘșȚțˆˇˉΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩάέήίαβγδεζηθικλμνξοπρςστυφχψωόύώﬁﬂ
		// Brazil:
		// 	0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÀÁÂÃÇÉÊÍÓÔÕÚàáâãçéêíóôõú
		// Russia:
		// 	<KEY>АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя
		// Turkey:
		// 	ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïð 0123456789ABCDEFGĞHIİJKLMNOPQRSŞTUVWXYZabcçdefgğhıijklmnoöpqrsştuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿıŁłŒœŠšŸŽžƒˆˇˉμﬁﬂĄąĘęÓóĆćŁłŃńŚśŹźŻż
		// LATAM:
		// 	0123456789ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚÜ abcdefghijklmnñopqrstuvwxyzáéíóúü

		return name.match(/[^\d\u00BF-\u1FFF\u2C00-\uD7FF\w _\.]+/g);
	}
	static validateSummonerNameInputLength(name){
		return name.length <= 16;
	}

	static validatePlatformId(_platformId){
		let isValid = false;
		if (_platformId && typeof _platformId === 'string'){
			isValid = typeof LeagueUtil.getPlatformIds().find(platformId => {
				return platformId === _platformId.toLowerCase();
			}) !== 'undefined';
		}
		return isValid;
	}

	static getPlatformIdForRegion(region){
		const mapping = LeagueUtil.getMappingRegionToPlatformId();
		if(!region){
			throw new ParameterError('region is missing');
{'fraction_non_alphanumeric': 0.08011806873286949, 'fraction_numerical': 0.031203879401222854, 'mean_word_length': 6.198786039453718, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '2800985', 'n_tokens_mistral': 2547, 'n_tokens_neox': 2668, 'n_words': 260}