src/components/PhoneNumber/components/Input.js
function e164(value, country_code, metadata)
{
	if (!value)
	{
		return undefined
	}

	// If the phone number is being input in an international format
	if (value[0] === '+')
	{
		// If it's just the `+` sign
		if (value.length === 1)
		{
			return undefined
		}

		// If there are some digits, the `value` is returned as is
		return value
	}

	// For non-international phone number a country code is required
	if (!country_code)
	{
		return undefined
	}

	// The phone number is being input in a country-specific format

	const partial_national_number = parse_partial_number(value, country_code).national_number

	if (!partial_national_number)
	{
		return undefined
	}

	// The value is converted to international plaintext
	return format(partial_national_number, country_code, 'International_plaintext', metadata)
}
function e164(value, country_code, metadata)
{
	if (!value)
	{
		return undefined
	}

	// If the phone number is being input in an international format
	if (value[0] === '+')
	{
		// If it's just the `+` sign
		if (value.length === 1)
		{
			return undefined
		}

		// If there are some digits, the `value` is returned as is
		return value
	}

	// For non-international phone number a country code is required
	if (!country_code)
	{
		return undefined
	}

	// The phone number is being input in a country-specific format

	const partial_national_number = parse_partial_number(value, country_code).national_number

	if (!partial_national_number)
	{
		return undefined
	}

	// The value is converted to international plaintext
	return format(partial_national_number, country_code, 'International_plaintext', metadata)
}
function e164 ( value , country_code , metadata ) { if ( ! value ) { return undefined } // If the phone number is being input in an international format if ( value [ 0 ] === '+' ) { // If it's just the `+` sign if ( value . length === 1 ) { return undefined } // If there are some digits, the `value` is returned as is return value } // For non-international phone number a country code is required if ( ! country_code ) { return undefined } // The phone number is being input in a country-specific format const partial_national_number = parse_partial_number ( value , country_code ) . national_number if ( ! partial_national_number ) { return undefined } // The value is converted to international plaintext return format ( partial_national_number , country_code , 'International_plaintext' , metadata ) }
Converts `value` to E.164 phone number format
Converts value to E . 164 phone number format