src/components/PhoneNumber/components/Input.js
function could_phone_number_belong_to_country(phone_number, country_code, metadata)
{
	// Strip the leading `+`
	const phone_number_digits = phone_number.slice('+'.length)

	for (const country_phone_code of Object.keys(metadata.country_phone_code_to_countries))
	{
		const possible_country_phone_code = phone_number_digits.substring(0, country_phone_code.length)
		if (country_phone_code.indexOf(possible_country_phone_code) === 0)
		{
			// This country phone code is possible.
			// Does the given country correspond to this country phone code.
			if (metadata.country_phone_code_to_countries[country_phone_code].indexOf(country_code) >= 0)
			{
				return true
			}
		}
	}
}
function could_phone_number_belong_to_country(phone_number, country_code, metadata)
{
	// Strip the leading `+`
	const phone_number_digits = phone_number.slice('+'.length)

	for (const country_phone_code of Object.keys(metadata.country_phone_code_to_countries))
	{
		const possible_country_phone_code = phone_number_digits.substring(0, country_phone_code.length)
		if (country_phone_code.indexOf(possible_country_phone_code) === 0)
		{
			// This country phone code is possible.
			// Does the given country correspond to this country phone code.
			if (metadata.country_phone_code_to_countries[country_phone_code].indexOf(country_code) >= 0)
			{
				return true
			}
		}
	}
}
function could_phone_number_belong_to_country ( phone_number , country_code , metadata ) { // Strip the leading `+` const phone_number_digits = phone_number . slice ( '+' . length ) for ( const country_phone_code of Object . keys ( metadata . country_phone_code_to_countries ) ) { const possible_country_phone_code = phone_number_digits . substring ( 0 , country_phone_code . length ) if ( country_phone_code . indexOf ( possible_country_phone_code ) === 0 ) { // This country phone code is possible. // Does the given country correspond to this country phone code. if ( metadata . country_phone_code_to_countries [ country_phone_code ] . indexOf ( country_code ) >= 0 ) { return true } } } }
Is it possible that the partially entered  phone number belongs to the given country
Is it possible that the partially entered phone number belongs to the given country